Kieran
Kieran

Reputation: 860

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 headphones?

Upvotes: 2

Views: 1206

Answers (1)

siliconeagle
siliconeagle

Reputation: 7383

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.

Upvotes: 2

Related Questions