Created
March 20, 2015 07:15
-
-
Save viizki/4ae39e25cb2448f24864 to your computer and use it in GitHub Desktop.
已插入耳机的情况下,仍然播放外音,而不使用耳机(如:打电话、播放音乐等)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); | |
try { | |
// setWiredDeviceConnectionState(int device, int state, String name); | |
Method method = AudioManager.class.getMethod("setWiredDeviceConnectionState", int.class, int.class, String.class); | |
method.invoke(audioManager, 4, 0, "headset"); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment