To be more specific, in my app there are recorder and accelerometer running in 2 services to record sleep cycle, and I need to make sure these 2 components stay up all night long (8 hours for example), how do I make sure they will not be killed or shut by the android system itself?
Although I doubt it will, because they are not memory/CPU intensive anyway, but just in case if this really happen.
To be more specific, in my app there are recorder and accelerometer running in
Share
There is no official way for you to be able to do this.
Instead, you could try uninstalling everything else on the device, and force stopping everything that can’t be removed. Also, put the device in airplane mode. Doing these three should be a good way to ensure that your device doesn’t run short on resources, as it won’t be doing much else.
However, logging data from the accelerometer for 8 hours will be very battery intensive, and your battery is likely to run out before 8 hours are up.