what code can disable headphone jack for an android(4.4) device

∥☆過路亽.° 提交于 2019-12-13 02:24:12

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/30322002/what-code-can-disable-headphone-jack-for-an-android4-4-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!