How can I check if headphones are currently plugged in. I don't want a broadcastreceiver which informs me when they have been connected to the device. I need something like:
if(/*headphone is connected*/)
...
If so, there's an intent to detect whether or not one is being plugged or unplugged: ACTION_HEADSET_PLUG . To check the status, you can use AudioManager. isWiredHeadsetOn() , although that may return false if there is also a bluetooth headset, and audio is routed to that instead.
Activate the Test Call or similar feature. Typically you do this by selecting a dummy contact labeled Test Call or something similar from your contacts list, and then initiate a call. When you speak into the microphone, you should be able to hear your voice played back over the headphones.
Clean the headphone jack It's possible that your phone can't get out of headphone mode because it has a lot of debris inside the audio jack. Dust, dirt, and even lint can build up inside. If you keep your phone inside your pocket regularly, lint can collect inside the jack.
It looks like you'll be interested in the isWiredHeadsetOn()
method and isBluetoothA2dpOn()
method of the AudioManager
class.
However, the isWiredHeadsetOn()
method is only available in Android 2.0 or later. (The isBluetoothA2dpOn()
method has been available since Android 1.5.)
Use this code snippet
AudioManager am1 = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
Log.i("am1.isWiredHeadsetOn()", am1.isWiredHeadsetOn()+"");
Log.i("am1.isMusicActive()", am1.isMusicActive()+"");
Log.i("am1.isSpeakerphoneOn()", am1.isSpeakerphoneOn()+"");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With