1

Im trying to build an app that can enable or disable the headphone jack on my Android 4.4 device . Once disabled nothing should be able to take control or activate it, even calling. I can root the device for this.

Any help would be appreciated.

jkb016
  • 439
  • 1
  • 7
  • 17
  • 1
    Check this previous answer: [here](http://stackoverflow.com/questions/20965530/how-to-mute-audio-in-headset-but-let-it-play-on-speaker-programmatically) – Ed Holloway-George May 19 '15 at 09:45
  • @EdGeorge: It sounds to me like the OP wants to do this system-wide, i.e. prevent the audio from all apps to be routed to the 3.5mm jack. The `setMode/setSpeakerPhone` method doesn't accomplish that. – Michael May 19 '15 at 14:09
  • Yup, I am trying to do it system wide – jkb016 May 19 '15 at 18:13

1 Answers1

0

As written here: How to mute audio in headset but let it play on speaker programmatically?

AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_IN_CALL);
am.setSpeakerphoneOn(false);

And then play the sound through the AudioManager.STREAM_SYSTEM stream.

When the sound's finished playing be sure to return the audio manager to its previous state or it'll stay on loudspeaker.

Community
  • 1
  • 1
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
  • I'll test and see if I can use this as a work around. I would like to point out that , I am not trying to play my own sound, I am trying to disable system from using headphone jack. – jkb016 May 19 '15 at 18:16