android - Check whether headphones are plugged in -


i can't seem find way know on android if headphones plugged in. found various solutions seem return false. thing seems work broadcastreceiver, that's not need:

i need this

if(headphones plugged in) { } 

is there such function? require special permissions?

you can use audiomanager.iswiredheadseton() checking if headset plugged in.

(don't worry deprecation, it's still usable only checking if headset plugged in.)

and need <uses-permission android:name="android.permission.modify_audio_settings" />

available in android 2.0 +


Comments