user2930077 user2930077 - 1 year ago 104
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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download