Have you connected headphones to your smartphone, but Android stubbornly ignores turning them off? Or is the system stuck in headset mode, even though you removed the plug a long time ago? Such bugs occur on devices from Samsung, Xiaomi, Realme and even Google Pixel - especially after updates or when using non-original accessories. In most cases, the problem is solved by software forcibly turning off the headphones through hidden commands ADB or automation.

In this article we will analyze 5 working methods from manual commands to automatic scripts that will return sound to the speakers. Important: some methods require root access or enabled Developer mode, but most solutions work without them. If your smartphone โ€œdoes not seeโ€ the disconnection of the 3.5 mm jack or Bluetooth headset, here you will find a solution for your model and version of Android.

Why Android does not disconnect headphones automatically

The reason for the bug lies in hardware or software failure audio port control. Here are typical scenarios:

  • ๐Ÿ”Œ Oxidation of contacts in the 3.5 mm connector (often on older ones Samsung Galaxy S or Note). The system โ€œthinksโ€ that the plug is still connected.
  • ๐Ÿค– Failure of the audioflinger driver โ€”the system process responsible for routing sound (relevant for Android 10โ€“14).
  • ๐Ÿ”„ Conflict with applicationsthat block the audio port (for example Dolby Atmos, ViPER4Android or games with exclusive sound).
  • ๐Ÿ“ฑ Incorrect firmware or custom software (for example, after root-hacking or installation LineageOS).

On devices With Type-C or USB-C port the problem may be related to incorrect operation of the adapter (especially cheap Chinese models sometimes โ€œstickโ€ in the system due to bugs in the stack Bluetooth A2DP.

๐Ÿ“Š What type of headphones are you having a problem with?
3.5 mm (mini-jack)
Bluetooth
USB-C/Type-C
I donโ€™t know

Before proceeding with software methods, check the mechanical reasons:

  1. Wipe the connector with a cotton swab with a stick dipped in alcohol (for 3.5 mm).
  2. Reboot your smartphone - sometimes this resets the audio driver state.
  3. Connect and disconnect the headphones 3-5 times in a row (to reset the recognition trigger).
โš ๏ธ Attention: If after reboot the problem remains, but in Settings โ†’ Sound the connected headset is displayed - this is a 100% software failure. Then only forced shutdown will help.

Method 1: Disconnection through the engineering menu (codes) USSD)

Many smartphones (especially Samsung, Huawei, Xiaomi) have hidden engineering menuss that allow you to reset the audio port state. To do this, USSD codes are used, which are entered as a phone number.

List of working codes for different brands:

Manufacturer Code What to do in the menu
Samsung #0# Go to Audio โ†’ Headset and select Disable.
Xiaomi/Redmi/POCO ##36446337## In the section Audio find Headset Mode and reset to Off.
Huawei/Honor ##2846579## ProjectMenu โ†’ Audio โ†’ Headset Detect โ†’ Disable.
Google Pixel ##4636## Tab Audio โ†’ Wired Headset โ†’ Force Disable.

If the code did not work:

  • ๐Ÿ“ฑ Try entering it through the standard application Phone, and not through third-party dialers.
  • ๐Ÿ”„ For some models Samsung (for example, Galaxy S22) the engineering menu is blocked - in this case only ADB (method 2).
  • ๐Ÿ› ๏ธ You may need to enable OnePlus And Oppo may need to be enabled Developer mode before entering the code.
โš ๏ธ Attention: Do not change others parameters in the engineering menu if you are not sure of their purpose. Incorrect settings can lead to complete loss of sound or microphone failure.

Method 2: Forced shutdown via ADB

Android Debug Bridge (ADB) is the most reliable method Disable the headphones programmatically if the engineering menu is not available. The method works on any version of Android (from 5.0 to 14) and does not require root access.

What you will need:

  • ๐Ÿ–ฅ๏ธ A computer with Windows/Linux/macOS.
  • ๐Ÿ“ฑ Enabled Developer mode i USB debugging on the smartphone.
  • ๐Ÿ”— Installed drivers ADB (you can download from the official Android website).

Step-by-step guide:

  1. Connect your smartphone to your PC via USB and select the mode File transfer (MTP).
  2. Open the command line (Windows) or terminal (Linux/macOS) and enter:
    adb devices

    Make sure that the device is detected (its serial number should appear number).

  3. Run the command to reset the audio port state:
    adb shell settings put global wired_headset_connected_state 0
  4. Restart the smartphone.

โ˜‘๏ธ Preparing for ADB commands

Done: 0 / 4

If the command does not work, try an alternative option (for Android 10+):

adb shell am broadcast -a android.intent.action.HEADSET_PLUG --es state 0 --es name "Headset"

For Bluetooth headset use:

adb shell am broadcast -a android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED --ez state false
โš ๏ธ Attention: On some firmware (for example, MIUI 14 or ColorOS 13) these commands may not work due to manufacturer restrictions. In this case, only manual editing of system files (method 4) or resetting the settings will help.

Method 3: Automation via Tasker or MacroDroid

If the headphones turn off incorrectly regularly, it makes sense to set up automatic correction through automation applications. The best options:

  • ๐Ÿค– Tasker (paid, but the most flexible).
  • โšก MacroDroid (free for basic tasks).
  • ๐Ÿ”„ Automate (visual flow editor).

Example of settings in MacroDroid:

  1. Create a new macro with the trigger Connecting headphones โ†’ Disabled.
  2. Add an action Run ADB command (root required) or Run script with the command:
    settings put global wired_headset_connected_state 0
  3. Set a delay of 2 seconds before execution (so that the system has time to register the shutdown).

For Tasker you will need a plugin ADB Plugin (costs ~100 rubles in Play Market). The script will look like this:

Profile: Headset Disconnected (Event โ†’ Hardware โ†’ Headset Unplugged)

Task:

1. Wait: 2 seconds

2. Run Shell: settings put global wired_headset_connected_state 0 (Run as Root: Off)

3. Wait: 1 second

4. Media Volume: 70% (so that the sound returns to the speakers)

๐Ÿ’ก

If the automation works too often, add a condition by time (for example, only during the day) or by battery level (so as not to disturb at night).

The advantage of this method is automatic bug fix without manual intervention. Minus: on some firmware (for example, Flyme from Meizu) Tasker may not have access to sound settings.

Method 4: Editing system files (for root only)

If the previous methods did not help, and you have root access, you can manually reset the audio port state by editing system files. This method is risky - incorrect changes can lead to loss of sound completely!

Instructions:

  1. Install a file manager with root access (for example, Root Explorer or FX File Explorer).
  2. Go to the path:
    /data/data/com.android.providers.settings/databases/settings.db
  3. Open the file in the SQL editor (for example, via SQLite Editor).
  4. Find the table system and the line with the parameter wired_headset_connected_state.
  5. Change the value to 0 and save the changes.
  6. Restart the smartphone.

For Bluetooth headset a similar parameter can be stored in:

/data/data/com.android.bluetooth/databases/bluetooth.db

Look for the table devices and field connected - set it in 0 for the problematic devices.

โš ๏ธ Attention: Before editing system files be sure to make a backup via TWRP or Orange Backup. An error can lead to bootloop (loop reboot)!
What to do if the sound disappears after editing?

If after changes in system files the sound disappeared completely, try:

1. Return the original parameter values.

2. Clear cache and application data Settings (com.android.settings).

3. Reset the sound settings via ADB:

adb shell pm clear com.android.providers.settings

If all else fails, restore the backup or reflash the smartphone.

Method 5: Reset the sound settings (without data loss)

If the software methods did not work, and hardware problems (oxidation, connector failure) no, only resetting the sound settings will help. This is safer than a full reset to factory settings.

Instructions:

  1. Go to Settings โ†’ Applications โ†’ Manage applications.
  2. Find application Settings (com.android.settings) and press Storage โ†’ Clear data.
  3. Confirm the action. Attention: this will reset all personal settings (wallpaper, brightness, gestures), but will not affect files and applications.
  4. Restart your smartphone.

For devices with MIUI (for example, Xiaomi Redmi Note 12):

  1. Open Settings โ†’ About phone.
  2. Click 5 times on MIUI versionto activate Advanced settings.
  3. Go in Additional โ†’ Reset settings โ†’ Reset sound settings.

After reset:

  • ๐Ÿ”Š Check the operation of the speakers through the built-in test (in the engineering menu or through the code ##0283## for Samsung).
  • ๐ŸŽง Connect and disconnect the headphones 2-3 times so that the system is retrained to recognize the state of the port.
๐Ÿ’ก

Resetting the sound settings is the safest way to return the audio port to working if the problem is caused by software and not hardware.

What to do if nothing helps

If all of the above methods do not work, the problem is most likely hardware. Here's what to check:

  • ๐Ÿ”Œ 3.5 mm jack: inspect the contacts for oxidation or mechanical damage. data-i="240">soldered contacts often come off. Samsung Galaxy A And J-series The soldering of the contacts often comes off.
  • ๐Ÿ“ฑ USB-C/Type-C port: if the headphones are connected via an adapter, try a different cable - the problem may be there.
  • ๐Ÿ”‹ Audio codec board: on older smartphones (for example, Sony Xperia Z3) it may fail due to overheating.
  • ๐Ÿ”„ Firmware: if the failure appeared after an update, rolling back to a previous version of Android may help (but requires unlocking bootloader).

To diagnose hardware problems:

  1. Connect the headphones to another device - if they work, the problem is in the smartphone.
  2. Try other headphones (preferably original ones) - if they are detected correctly, the cable or adapter.
  3. Check the sound through Bluetooth โ€”if it works, the problem is definitely in the connector or audio path.

If the diagnosis is confirmed, repair options:

Problem Solution Cost (approx.)
Oxidation of the 3.5 mm connector Cleaning with alcohol + soldering contacts 500โ€“1 500 โ‚ฝ
Failure of the audio codec Replacing the chip or the entire motherboard 2 000โ€“8 000 โ‚ฝ
Problems with USB-C port Replacing the connector + checking the power circuits 1 500โ€“4 000 โ‚ฝ
โš ๏ธ Attention: On new smartphones (for example, Samsung Galaxy S23 or Google Pixel 7), the audio codec is often integrated into the main processor. In this case, the repair may cost as much as a new phone.

FAQ: Frequently asked questions

Is it possible to disable headphones without root and ADB?

Yes, try engineering menu (method 1) or resetting sound settings (method 5). If this does not help, only hardware checks remain.

Why, after disconnecting the headphones, does the sound go only to the left/right speaker?

This is a sign damage to the audio path or a failure in the balance settings. Check in Settings โ†’ Sound โ†’ Stereo balance. If the adjustment does not help, the problem is in the hardware (for example, one of the speakers has become unsoldered).

The headphones turn off, but the sound remains in them. How to return it to the speakers?

This is a sound routing bug. It will help:

  1. Restart the smartphone.
  2. ADB command: adb shell media volume --stream 3 --set 50 (set the media volume to 50% and reset the route).
  3. Deleting the application cache Android System Media (com.android.media).
Not a single method works. What to do? Xiaomi Not a single method works. What to do?

ADB commands are often blocked. Try: MIUI ADB commands are often blocked. Try:

  1. Install Magisk and module Disable Flag Secure to unlock hidden functions.
  2. Use an alternative ADB client, for example Scrcpy, to send commands.
  3. Roll back to an older version MIUI (if the problem appeared after the update).
Is it possible to fix the problem through TWRP?

Yes, if you have custom recovery installed. Go to Advanced โ†’ File Manager and manually delete the files:

/data/data/com.android.providers.settings/databases/settings.db

/data/data/com.android.bluetooth/databases/bluetooth.db

After a reboot, the sound settings will be reset to factory settings.