Android Emulator - how to imitate a headset connection

Android Emulator - how to emulate a headset.

  • Is it possible to simulate the action of a connected headset?

  • Basically, I want this intention to be Intent.ACTION_HEADSET_PLUG - Intent.ACTION_HEADSET_PLUG . Is there any other way to do this differently than simulate a connected headset?

+6
source share
2 answers

In the official link on the Android emulator:

Emulator Limitations:
In this release, emulator restrictions include:

  • There is no support for headphones connected to the device.

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

+5
source

If you are trying to turn on the headset, you can try the following:

 AudioManager manager = (AudioManager)Context.getSystemService(Context.AUDIO_SERVICE) manager.setBluetoothScoOn(boolean on); 
0
source

Source: https://habr.com/ru/post/894163/


All Articles