7

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?

Turdaliev Nursultan
  • 2,538
  • 1
  • 22
  • 28
jumpa
  • 658
  • 1
  • 9
  • 22

3 Answers3

5

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?)

iDroid
  • 10,403
  • 1
  • 19
  • 27
0

You can try Lesser AudioSwitch app. It will let you switch input (and output) devices manually. Here is the quick instruction on how to use it

This program tricked Smule that I was running on emulator. Smule requires headset to record audio, and no other methods worked to trick Android, except Lesser AudioSwitch

druss
  • 1,820
  • 19
  • 18
0

If you are trying to turn on the headset then you could try this:

AudioManager manager = (AudioManager)Context.getSystemService(Context.AUDIO_SERVICE)
manager.setBluetoothScoOn(boolean on);
Turdaliev Nursultan
  • 2,538
  • 1
  • 22
  • 28
A. Abiri
  • 10,750
  • 4
  • 30
  • 31