Have you noticed how your favorite app suddenly closes in the background, losing game progress or important data? On Xiaomi smartphones, this problem is especially relevant because of the aggressive optimization of MIUI, which forcibly clears the background processes. The solution is: fix the application in RAM (RAM), which will prevent it from automatically closing and speed up the re-launch.
In this article, you'll learn how to lock an app into memory on any Xiaomi, Redmi, POCO or Black Shark device, from budget models to flagships. We'll look at both standard methods through MIUI settings and hidden features for power users. Importantly, not all applications can be fixed, and some methods require ADB or bootloader unlocking. But most instructions work without root rights.
Before you start, check your firmware version: Settings path โ About Phone โ MIUI version. Current methods were tested on MIUI 12-15 (including HyperOS for new models). If you have an older version, update the system first.
Why Xiaomi Closes Apps in the Background and How to Fix It
Xiaomi smartphones are known for aggressive RAM optimization, which is due to the features of MIUI firmware, which prioritizes energy efficiency over multitasking.
- ๐ฎ Games (e.g. Genshin Impact or PUBG Mobile) departs when switching to another chat.
- ๐ฌ Messengers (Telegram, WhatsApp) do not send notifications in a timely manner.
- ๐ต Music players (Spotify, YouTube Music) stop after 5-10 minutes in the background.
- ๐ Tracking apps (like Strava) lose data when they lock the screen.
The reason lies in the mechanism of Memory Management, which forcibly kills processes if:
- ๐ Battery level below 15%.
- ๐ The phone has not been used for a long time (the screen is off for more than 30 minutes).
- ๐ Too many applications running at the same time (background process limit exceeded).
- ๐ Power Saving Mode or Ultra Battery Saver.
The attachment of the application to RAM removes these restrictions for the selected programs.
โ ๏ธ Note: Fixing an application in memory increases battery consumption by 5-15%. Do not attach more than 3-4 applications at the same time - this can lead to system lags.
Method 1: Fixing through MIUI settings (without root)
The easiest method is to use the built-in โStickโ feature in the multitasking menu, which works on all Xiaomi devices with MIUI 12 and later, including POCO and Redmi.
Step-by-step:
- Open the application you want to secure (e.g. Telegram).
- Click the "Recent Apps" button (square or swipe up from the bottom panel).
- Find the card of the desired application and make a long press on its title.
- In the menu that appears, select "Secure" (icon with a pin) ๐).
- Confirm the action by clicking "Secure" in the dialog box.
Now the app will remain in memory even when you clear the RAM through the "Close All" button to undo the fixing:
- ๐ Open the multitasking menu again.
- ๐ Find the attached application (it will be marked with a pin).
- ๐ฑ๏ธ Make a long press and select "Unlock".
Limitations of the method:
- โ Does not work for system applications (e.g. com.android.systemui).
- โ Maximum can be fixed to 4 applications at the same time.
- โ After restarting the phone, the fixing is reset.
โ๏ธ Preparation for securing the annex
Method 2: Setup autostart and background activity
If standard anchoring doesnโt work (like WhatsApp or Viber), try setting up autostart and background activity to prevent the system from killing the process.
Instructions:
- Go to Settings โ Applications โ Application Management.
- Select the application you want (such as Spotify).
- Slip on AutoRun and turn on the slider.
- Go back and select "Background Activity" โ set "No Limits".
- In the "Energy consumption" section, select "No restrictions".
- Restart your phone to apply the changes.
For some applications (for example, messengers) it is also useful:
- ๐ Enable "Show notifications" in the application settings.
- ๐ถ Allow "Autostart in Mobile Data" (if using mobile Internet).
- ๐ Disable "Battery Optimization" for the application.
This method does not fix the application in RAM on a permanent basis, but it significantly reduces the likelihood of it being closed.
โ ๏ธ Attention: Setting up "No Limits" for more than 5 apps can lead to increased battery consumption and overheating of the processor. โ Battery โ Battery status.
| Annex | Recommended settings | Expected impact |
|---|---|---|
| Telegram | Auto Start + Background Activity + Notifications | Instant notifications, no chat loss |
| Spotify/YouTube Music | Background activity + Without battery restrictions | Music Plays in the Background >1 Hours |
| PUBG Mobile/Genshin Impact | Fixing in RAM + Performance Mode | No departures when switching to the messenger |
| Google Maps/Yandex.Navigator | Auto Launch + Exact Location | Navigation works in the background without failure |
Method 3: Using ADB for Forced Attachment (Advanced)
If standard methods don't work, you can use Android Debug Bridge (ADB), a debugging tool that allows you to manage system settings, which does not require root, but requires a connection to a computer.
What you need:
- ๐ฅ๏ธ Computer with Windows, macOS or Linux.
- ๐ USB-cable (preferably original).
- ๐ฅ Installed Xiaomi drivers (official website).
- ๐ ๏ธ Utility. ADB (Download Platform Tools).
Step-by-step:
- Turn on Developer Mode: Go to Settings โ About Phone. Tap 7 times on MIUI Version. Enter your password if you need to.
"Debugging by USB"
- Back to Settings โ Additionally. โ For developers.
- Turn on the USB debugging slider.
- Confirm the action by pressing โOKโ in the dialog box.
- Connect the phone to your computer and select File Transfer mode.
- Open the command prompt (or Terminal on macOS/Linux) in the ADB folder.
- Enter the command to check the connection: Adb devices must appear serial number of your device.
- Give permission to fix in memory: adb shell cmd appops set <package_name> RUN_ANY_IN_BACKGROUND allow Replace <package_name> to the application ID (e.g. com.whatsapp for WhatsApp).
- For compulsory exclusion from optimization, enter: adb shell dumpsys deviceidle whitelist +<package_name>
Now, after each reboot, Tasker will automatically pin selected apps to memory. For multiple applications, add individual commands via a separator;
cmd appops set com.whatsapp RUN_ANY_IN_BACKGROUND allow; dumpsys deviceidle whitelist +com.whatsapp
cmd appops set org.telegram.messenger RUN_ANY_IN_BACKGROUND allow; dumpsys deviceidle whitelist +org.telegram.messengerAdvantages of the method:
- โ It works without root.
- โ Automating routine activities.
- โ Allows you to secure an unlimited number of applications.
Disadvantages:
- โ Requires customization and understanding of Tasker.
- โ It may be in conflict with other automation systems.
- โ Increases the load on the processor when the system is loaded.