In my application, I want to record the phone's location at fixed interval. To do that, I have a TimerTask
to record the location on a regular basis and a WakeLock
for the recording to continue even when the phone is aslept.
My problem is that the Wakelock
doesn't prevent the app from going into the "Stop" state when it is no longer displayed in the foreground. As a consequence, my app is regularly, but apparently randomly, destroyed by the system (no crash and no call to onDestroy
), and the recording stops.
How can I keep my recording process going even if my app goes into the background?