0

The problem is that wired headset it seems has priority higher then BT headset. So this snippet doesn't resolve the problem

AudioManager audioManager = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE);    

audioManager.setMode(AudioManager.MODE_IN_CALL); // also tried with AudioManager.MODE_IN_CALL
audioManager.setBluetoothScoOn(true);
audioManager.startBluetoothSco();

MediaPlayer mMediaPlayer = MediaPlayer.create(AudioTests.this, R.raw.test_cbr);
mMediaPlayer.start();
Kiryl Ivanou
  • 1,015
  • 2
  • 12
  • 22

1 Answers1

0

While it is hackish, directly reflecting on AudioSystem may give you access to this functionality. I haven't yet implemented this, but I know that there are commercial apps which provide this ability (see the "SoundAbout" app in the market).

        Class reflectedAS = null;
        reflectedAS = Class.forName("android.media.AudioSystem");

Then, there is a function called "setDeviceConnectionState" that looks like it will do the trick. If I get this working, I'll update the answer, but wanted to provide you a starting place (and for others as well who come across this).

Source code for AudioSystem: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.3_r2.1/android/media/AudioSystem.java#AudioSystem

Do not expect this to work on all versions of Android, or to be supported in future releases

That said, not sure of another way to do this.

jjmilburn
  • 380
  • 3
  • 12