I have an application we use for research purposes that collects data from sensors in background. I use a service that registers some broadcast receivers, with startForeground()
attached to a notification and also I start the service in onStartCommand()
using START_STICKY.
Everything works fine on Marshmallow but when I try it on a OnePlus 3 with 7.1.1 after a while the application just disappears from the running applications.. everything gets killed by the system. Sometimes I get a system notification saying: "Attention, An application running in background is using a lot...". If I click this notification it opens the Settings window that says "Manage high power usage apps", my app is there but the option "Auto close high power usage apps" is disabled.
Moreover, I already set the app as "do not optimize" in the system settings under Battery. Actually if I disable the logging from those sensors that consume more battery such as Location everything works fine, i can run the application for an unlimited amount of time. Any suggestion on how to solve?
Please remember that this is an application for research purposes, it is not published, so do not suggest to not do this because it can affect the user experience, this is not the case. Thank you!