在 Android 中,如何在有线耳机和 A2DP BT 耳机之间切换?
在我的应用程序中,我允许用户在内置听筒扬声器、扬声器和立体声 BT (A2DP) 耳机之间切换音频输出。如果插入有线耳机,则无法选择内置扬声器或 A2DP。无论哪种方式,声音都会通过有线耳机播放。有什么办法可以强制通过BT耳机播放吗?
使用 API 5 及更高版本,所有隐式设置音频路径的方法均已弃用,因此我无法找到实现此目的的方法。任何帮助将不胜感激。
谢谢。
In my app, I allow the user to switch the audio output between the internal handset speaker, the speakerphone, and a stereo BT (A2DP) headset. If a wired headset is plugged in, it's impossible to select the internal speaker or A2DP. Either way, the sound plays through the wired headset. Is there any way to force it to play through the BT headset?
Using API 5 and higher, all the methods that implicitly set the audio path are deprecated, so I can't figure out a way to do this. Any help would be appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果插入有线耳机 + BT 耳机,则可以切换到内置扬声器(如果您指的是 Android 设备扬声器)或有线耳机,
但在这种情况下,切换到 BT 耳机会出现问题。此代码无助于切换到
if wired headset + BT headset is plugged in then it's possible to switch to internal speaker (if you mean android device speakers) or wired headset
But in this case it's problem to switch to BT headset. This code doesn't help to switch to