0

My phone not detect headphone when I plug my headphone. So I want turn on headphone mode manually to listen by headphone instead by speaker. Can I do it by code? Thank you so much!

  • 2
    Possible duplicate of [How to detect when a user plugs headset on android device? (Opposite of ACTION\_AUDIO\_BECOMING\_NOISY)](https://stackoverflow.com/questions/13610258/how-to-detect-when-a-user-plugs-headset-on-android-device-opposite-of-action-a) – Rob Sep 02 '18 at 01:45

1 Answers1

0

I think this might help

AudioManager mAudioMgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
mAudioMgr.setMode(AudioManager.MODE_IN_COMMUNICATION);
         mAudioMgr.setSpeakerphoneOn(false);
         mAudioMgr.setWiredHeadsetOn(true);
Ashish Kumar
  • 374
  • 4
  • 11