user2930077 user2930077 - 3 days ago 5
Android Question

How to hide headset icon?

If headset was plugged an icon of headset is appeared in status bar.

How to hide headset icon in status bar ? I know that is possible in application


AudioManager has private method which is accessible using reflection.

AudioManager manager = (AudioManager) aContext.getSystemService(Context.AUDIO_SERVICE);
    try {
        int deviceType = AudioSystem.DEVICE_OUT_WIRED_HEADSET;
        // turn off headset
        int state = 0;
        Class<?> cl = Class.forName("");
        Method method = cl.getMethod("setWiredDeviceConnectionState", new Class[] {
                Integer.TYPE, Integer.TYPE, String.class });
        method.invoke(manager, new Object[] { deviceType, state, "device" });
    } catch (Exception e) {
        iLog.error("disableHeadset, exception {}", ExceptionUtils.getStackTrace(e));

All voice passes to earpiece instead headset