开发者

Android: Detect headphones as well as headset?

I've got my code working using the isWiredHeadsetOn() method in AudioManager as long as I use the headset that came with my phone. If I use a pair of headphones without an inbuilt microphone, isWiredHeadsetOn() returns false, which I suppose is fair enough, but isn't what I want! Is there a way to detect both headsets and开发者_如何学Python headphones?


The best way is to use a broadcast receiver for ACTION_HEADSET_PLUG. Then you get events when the headset is connected or disconnected.

I think it should work for bluetooth devices but am not 100% sure to be honest.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜