jumpa jumpa - 23 days ago 12
Android Question

Android Emulator - How to emulate headset plugging action

Android Emulator - How to emulated headset plugged.


  1. Is it possible to simulate the action of a headset being plugged in?

  2. Basically, I want this intent fired -
    Intent.ACTION_HEADSET_PLUG
    . Is there any other way to do this other than simulating a headset being plugged in?


Answer

From the official reference on Android emulator:

Emulator Limitations:
In this release, the limitations of the emulator include:

  • No support for device-attached headphones

Perhaps you could test it with mock objects and events? (JUnit?)