开发者

How to detect if BT headset is connected in Android SDK?

开发者 https://www.devze.com 2023-01-24 23:34 出处:网络
I made an app that plays back audio files, and has an option to switch the audio path between the headset, speaker, and a BT headset. However, I can\'t figure out a way to have the app detect if there

I made an app that plays back audio files, and has an option to switch the audio path between the headset, speaker, and a BT headset. However, I can't figure out a way to have the app detect if there is a BT headset connected. I can check if BT is enabled or disabled, and I can check if there are any devices paired, but not if any are connected. The only thing I can do for now is use a BroadcastReceiver to see 开发者_JS百科when the "android.bluetooth.headset.action.STATE_CHANGED" broadcast is made and check if it's connected. However, this only work when the headset is connected or disconnected. I'd like a solution that would let my app check th BT headset state whenever it needs to. How can this be done?

0

精彩评论

暂无评论...
验证码 换一张
取 消