Android Emulator - How to emulated headset plugged.
Is it possible to simulate the action of a headset being plugged in?
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?
hi try by enabling the audio recording support while creating the virtual device in emulator... While creating device go to hardware part and select new button. A dialog will appear in which select the property combo and select "Audio Recording Support" and give k and apply...
AudioManager audioManager = (AudioManager)getSystemService(Context. AUDIO_SERVICE); audioManager. isWiredHeadsetOn(); (Don't worry about the deprecation, it's still usable for ONLY checking if the headset are plugged in.)
From the official reference on Android emulator:
Emulator Limitations:
In this release, the limitations of the emulator include:
Perhaps you could test it with mock objects and events? (JUnit?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With