Turn off System Settings > Apps > Gear Icon > Special Access > Battery Optimization.
WARNING: Recently OnePlus phones started reverting this setting randomly for random apps. So if you set it to be not optimized, the next day it may be back to optimized.
To avoid the system to automatically revert the not optimized setting, you must also lock the app into the ‘Recent App’ list. (solution described here)
Start the app you want to protect. Go to Recent apps (App switcher). Toggle the Lock button on the upper right corner of the app.
This will avoid the app to be killed in background and the Battery optimisation setting to be reverted.
This is however not 100%. You may have to check system settings every once in a while. See a bug report filed to OnePlus.
Turn off System settings > Battery > Battery optimization, switch to ‘All apps’ in top right menu > Your app > Don’t optimize
NOTE: Some of our users indicated that you need to disable Doze mode in Developer options in 1+3 and earlier.
App Auto-Launch (on some OnePlus phones) essentially prevents apps from working in the background. Please disable it for your app.
Enhanced / Advanced optimization
- OnePlus 6 and further:
System settings > Battery > Battery optimization > (three dots) > Advanced optimization.
You’ll see two options there. Both are enabled by default:
- Deep optimization
This is the main app killer. If you need any apps to run in background, disable it.
- Sleep standby optimization
OnePlus tries to learn when you are usually asleep, and in those times it will then disable the phone’s network connections. This setting will prevent push notifications from being delivered.
- Deep optimization
- OnePlus below 6:
Turn off System settings > Battery > Battery optimization > (three dots) > Enhanced optimization.
NOTE: This should help with the problem where you lose Bluetooth connection to your smartwatch / fitness tracker (e.g. for sleep tracking).
Recent apps clearing behaviour
Normally when you swipe an app away, it won’t close. Android handles that well on its own. On OnePlus this may however work in a different way. Recent app clear behaviour manager might be set up in a way that swiping the app to close will kill it.