1. Disable Battery Optimization for the App
- 
Go to:
Settings > Apps > Manage apps - 
Find your app and tap it.
 - 
Tap Battery saver.
 - 
Set it to No restrictions.
 
🔒 2. Lock the App in the Recents Menu
- 
Open the app.
 - 
Go to the Recent apps screen (swipe up and hold or use the task button).
 - 
Swipe down on the app preview or tap and hold it.
 - 
Tap the lock icon. This prevents the app from being cleared automatically.
 
⚙️ 3. Turn Off MIUI Optimizations (Advanced)
⚠️ This may have side effects and is more technical.
- 
Go to
Settings > About phone. - 
Tap MIUI version multiple times until Developer Options are enabled.
 - 
Go to
Settings > Additional settings > Developer options. - 
Scroll down and turn MIUI optimization OFF.
 
🔋 4. Disable Battery Saver
- 
Go to
Settings > Battery. - 
Turn off Battery Saver or Ultra Battery Saver.
 
📲 5. Auto Start Permission
- 
Go to
Settings > Apps > Manage apps. - 
Tap the app.
 - 
Tap Autostart and enable it.