问题描述
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 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.