Have you noticed that Android spontaneously closes applications in the background, interrupting downloads, notifications or music? This is not an accident, but the work of the built-in optimization mechanism RAM and the battery. The system believes that freeing up memory improves performance, but it often interferes with users: for example, when Telegram stops syncing messages or Spotify cuts off playback after 10 minutes of inactivity.

The problem is aggravated on devices with small volume RAM (2โ€“4 GB) and on firmware from manufacturers like Xiaomi, Huawei or Samsung, which aggressively optimize background processes. In this article we will look at preventing Android from killing applications - from basic settings to advanced methods with 5 proven methods prevent Android from killing apps - from basic settings to advanced methods with ADB. All instructions are relevant for Android 10โ€“14, but some points may differ depending on the shell (MIUI, One UI, ColorOS etc.).

Why does Android close background applications?

The reason lies in the architecture Android: the system uses memory management mechanism (Low Memory Killer, or LMK), which forcibly terminates processes when there is a shortage RAM. The less free memory, the more aggressively Android cleans the background. Manufacturers are aggravating the situation with their โ€œtricksโ€:

  • ๐Ÿ”‹ Battery optimization: MIUI (Xiaomi/Redmi/Poco), EMUI (Huawei) and One UI (Samsung) block background activity to save battery.
  • ๐Ÿงน Auto-clean memory: on devices with 4 GB of RAM or less, the system can kill applications every 5-15 minutes of inactivity.
  • ๐Ÿ“ฑ Manufacturers are "improving" Android: for example, Oppo/Realme in ColorOS add a feature "Deep optimization", which forcibly freezes applications.

Another culprit is Doze Mode (sleep mode), which is activated when the device lies motionless. In this mode, Android limites network activity and background tasks, which leads to losing notifications from instant messengers and stopping downloads..

โš ๏ธ Attention: Disabling memory optimization can increase battery consumption by 10-25% and cause lags on weak devices. Before making changes, check the free memory in Settings โ†’ Memory.

Method 1: Disable battery optimization for a specific application

The safest method is exclude the application from battery optimization mode. This does not cancel the restrictions LMK, but allows the app to work longer in the background. Instructions:

  1. Open Settings โ†’ Applications.
  2. Select the desired application (for example, VK Music or Google Maps).
  3. Go to Battery โ†’ Battery optimization (on some devices the path may differ: Settings โ†’ Device maintenance โ†’ Battery โ†’ Background activity).
  4. Select "All applications" โ†’ find yours โ†’ install "Do not optimize".

On Xiaomi i Redmi Additionally you need:

  • ๐Ÿ”„ Go to Settings โ†’ Applications โ†’ Permissions โ†’ Autorun and enable autorun for the application.
  • ๐Ÿ“ฑ V Settings โ†’ Battery and performance โ†’ Application battery management select "No restrictions".

Enable application autostart

Disable battery optimization

Add to "Protected Applications" (if any)

Reboot the device-->

On Samsung (One UI) the path is different:

  1. Settings โ†’ Device Maintenance โ†’ Battery.
  2. Tap on the three dots (โ‹ฎ) โ†’ "Battery settings".
  3. Select "Applications running in the background mode" โ†’ add your application to the list.
โš ๏ธ Attention: On some firmware (for example, EMUI 12+ from Huawei), these settings may be reset after updating the system. Check them every 1-2 months.

Method 2: Use "Application Lock" in multitasking

Many shells (MIUI, Flyme, ColorOS) allow pin the application in memoryso that it does not close when minimized. How it works:

  1. Open recent applications (swipe up with a delay or the "โ–ก" button).
  2. Find the desired application (for example, YouTube Music) and swipe down (on Xiaomi) or tap on the icon ๐Ÿ”’ (on Samsung).
  3. The application will be marked as "Blocked" and will not close when cleared RAM.

Method limitations:

  • โŒ Works only while the application hangs in recent. After a reboot, the lock is reset.
  • โŒ Not all shells support this function (for example, on stock Android it is not).
  • โœ… Suitable for a temporary solution (for example, to Google Maps not close during navigation).
๐Ÿ’ก

On some devices (for example Realme Narzo), the blocking only works for 1-2 applications at the same time. If you block the third, the first will automatically be unblocked.

Method 3: Developer settings - limit background processes

For advanced users there is a way reduce aggressiveness LMK via Developer settingsThis will not disable closing applications completely, but will increase their operating time. background.

First enable developer mode:

  1. Settings โ†’ About phone โ†’ Build number (tap 7 times).
  2. Go back to Settings โ†’ System โ†’ For Developers.

Now change the following parameters:

Option Recommended value Effect
Limit of background processes 4 processes Increases the number of applications that can run in the background simultaneously.
Do not save actions Disabled Prevents applications from being killed when minimized (but increases battery consumption).
Limit background processes Disabled Prevents the system from aggressively clear RAM.
Animation of windows / Animation of transitions Disabled (0x) Indirectly speeds up switching between applications, reducing the load on RAM.

After changes reboot the device. The effect will not be noticeable immediately: the system may still close applications, but less often. On weak devices (for example, Redmi 9A with 2 GB of RAM), this may lead to slowdowns.

โš ๏ธ Attention: On Android 12+ Some options (for example Background process limit) may be hidden or not work due to Google restrictions. In this case, use ADB (method 4).

MIUI (Xiaomi/Redmi/Poco)

One UI (Samsung)

ColorOS (Oppo/Realme)

EMUI (Huawei)

Stock Android (Pixel/Motorola/Nokia)

Other-->

Method 4: ADB commands to completely disable optimization

If the previous methods did not help, the only thing left is advanced method - disable optimization via ADB (This requires connecting to a computer. but gives maximum control.

What you will need:

  • ๐Ÿ–ฅ๏ธ Computer with Windows/macOS/Linux.
  • ๐Ÿ”Œ Cable USB (preferably original).
  • ๐Ÿ“ฑ On mode USB debugging (in Settings โ†’ For developers).
  • ๐Ÿ› ๏ธ Utility ADB (download from official website).

Step-by-step guide:

  1. Connect your phone to the PC and allow debugging (a request will appear on the phone screen).
  2. Open Command Line (Windows) or Terminal (macOS/Linux) in the folder with ADB.
  3. Enter the command to check the connection:
    adb devices

    The serial number of your device should appear.

  4. Disable optimization for a specific application (replace com.example.app on your application package, for example com.whatsapp):
    adb shell dumpsys deviceidle whitelist +com.example.app
  5. Disable Doze Mode for the application:
    adb shell dumpsys battery unplug
    

    adb shell dumpsys deviceidle force-idle

    (These commands simulate connecting to a charger, which disables sleep mode.)

To find the application package, use the command:

adb shell pm list packages | grep "application_name"

for example, for Telegram:

adb shell pm list packages | grep "telegram"

How to find the application package without ADB?

Open the application page in Google Play โ†’ copy the URL (for example, https://play.google.com/store/apps/details?id=com.whatsapp). After id= there will be a package (com.whatsapp).

Effect of ADB-commands:

  • โœ… The application will not be killed Doze Mode.
  • โœ… Notifications will arrive without delay.
  • โŒ After rebooting the phone or updating the system, the settings may be reset.
โš ๏ธ Attention: Some manufacturers (for example, Huawei) block commands for managing the battery. In this case, only root will help. ( ADB-commands for battery management. In this case, only root will help (root).

Method 5: Use third-party utilities (without root)

If you donโ€™t want to bother with ADB, you can use specialized applications. They do not provide a 100% guarantee, but they simplify setup. The best options:

Application Functions Restrictions
Greenify Allows you to manually put applications into hibernation, but can also prevent the system from killing them. Requires ADB for full operation. Free version with limitations.
Don't Kill My App! Shows what settings need to be changed for a specific phone model. Does not disable optimization itself, but only suggests what to do.
Background Mode (No Root) Simulates activity application so that the system does not kill it. Increases battery consumption. Does not work without Android 12+ without ADB.

Setting example Greenify:

  1. Install the application from Google Play.
  2. Enable USB debugging and connect to the PC.
  3. Run Greenify and select "Set up Greenify with ADB".
  4. Follow the instructions in the application to activate the advanced mode.
  5. Add the desired applications to the list and select "Hibernate" (sleep mode).

Important: third-party utilities do not guarantee 100% results, especially on new versions Android. Their effectiveness depends on the firmware and model. devices.

๐Ÿ’ก

On Android 13+ Google has tightened restrictions for background processes. Many utilities that worked on Android 9โ€“11are now useless without ADB or root.

What to do if nothing helps?

If all methods have been tried, and Android stubbornly closes applications, there are several radical solutions left:

  • ๐Ÿ”„ Reset settings to factory settings: sometimes it helps if the problem is caused by a conflict settings. Attention: will delete all data!
  • ๐Ÿ“ฑ Install custom firmware (for example, LineageOS or Pixel Experience). manufacturer optimizations, but require unlocking the bootloader.
  • ๐Ÿ”‹ Buy a phone with more RAM: on devices with 6+ GB RAM the problem is less common.
  • ๐Ÿ› ๏ธ Get root access and manually edit files /system/build.prop (only for experienced users!).

If you decide on custom firmware, keep in mind:

  • โœ… Pros: full control over system, there is no unnecessary optimization.
  • โŒ Disadvantages: loss of warranty, risk of โ€œbrickingโ€ the device, possible bugs with the camera or sensors.
โš ๏ธ Attention: On some models (for example, Samsung s Knox) receiving root or installing custom firmware will trigger the flag Knox and loss of the ability to use Samsung Pay, Secure Folder and other functions.

FAQ: Frequently asked questions

Why did Android start closing applications again after the update?

Manufacturers often reset optimization settings after updates. Check:

  1. Are permissions reset in Settings โ†’ Applications โ†’ Battery.
  2. Not updated Is there a firmware (for example, MIUI 13 โ†’ MIUI 14), where restrictions could be tightened.
  3. Have new functions appeared like "Adaptive battery" (on Android 12+).

If yes, repeat the settings from Methods 1โ€“3.

How to find out which application is killing my background one?

Use Logcat (included in Android SDK) or application Logcat Extreme:

  1. Connect your phone to PC and run adb logcat.
  2. Reproduce the problem (for example, close Spotify and wait until the music stops).
  3. In the logs, look for lines with "kill", "am kill" or "LMK".

Typical culprits: com.android.server.am.ActivityManagerService (system task manager) or com.miui.powerkeeper (on Xiaomi).

Will VPN work in the background if you disable optimization?

Yes, but with reservations:

  • If VPN is used Always-On VPN (setting in Settings โ†’ Network and Internet โ†’ VPN), it will work even with aggressive optimization.
  • For regular VPNs (for example, ProtonVPN) you need:
    1. Disable battery optimization (see Method 1).
    2. Add VPN to "Applications without restrictions" (if there is such an item).

The Android 10+ system may still kill the VPN if it is not actively used. In this case, only ADB will help (see Method 4).

Is it possible to disable optimization for all applications at once?

Technically yes, but this is highly not recommended. Consequences:

  • ๐Ÿ”‹ The battery will drain 2-3 times faster.
  • ๐Ÿข The device will start to slow down due to overload RAM.
  • ๐Ÿ”ฅ Risk of overheating (especially on weak processors like Snapdragon 4xx).

If you still want to try, use ADB-command:

adb shell settings put global hidden_api_policy 1
Attention: this disables hidden API restrictions, but may break the operation of some system ones. functions.

Why is there no such problem on the iPhone?

iOS uses a different approach to memory management:

  • ๐Ÿ Applications are not killed immediately after minimizing, but "frozen" (the state is saved in memory).
  • ๐Ÿ”„ The system itself decides when to release RAM, without aggressive cleaning.
  • โšก Battery optimization works differently: iOS does not block background tasks, but limits their activity.
  • However, iOS has its drawbacks: for example, it is impossible to manually clear RAM, and sometimes old applications remain hanging in the background, taking up memory.