Skip to content

Instantly share code, notes, and snippets.

@Volcanoscar
Forked from viizki/DisableHeadset.java
Last active August 29, 2015 14:25
Show Gist options
  • Save Volcanoscar/5303356f2136d4eabd93 to your computer and use it in GitHub Desktop.
Save Volcanoscar/5303356f2136d4eabd93 to your computer and use it in GitHub Desktop.
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