【问题标题】:How to switch to BT headset while wired headset is plugged in如何在插入有线耳机时切换到 BT 耳机
【发布时间】:2014-08-29 00:51:22
【问题描述】:

问题是有线耳机的优先级似乎高于 BT 耳机。所以这个sn-p不能解决问题

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 : 你想通过蓝牙发送音频吗?

标签: android bluetooth headset


【解决方案1】:

虽然它很老套,但直接反映在 AudioSystem 上可能会让您访问此功能。我还没有实现这个,但我知道有商业应用可以提供这种能力(参见市场上的“SoundAbout”应用)。

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

然后,有一个名为“setDeviceConnectionState”的函数看起来可以解决问题。如果我得到这个工作,我会更新答案,但想为您提供一个起点(以及其他遇到此问题的人)。

AudioSystem源代码:http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.3_r2.1/android/media/AudioSystem.java#AudioSystem

不要期望它适用于所有版本的 Android,或在未来的版本中得到支持

也就是说,不确定其他方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-17
    • 2010-10-26
    • 2013-01-27
    • 2017-04-24
    • 1970-01-01
    • 2012-10-06
    • 1970-01-01
    相关资源
    最近更新 更多