I have to write an application that executes a task at a specific interval. A task consists of recording some data, collected from GPS and other sensors, and occasionally making SQLite transactions.
The device (a smartwatch with 4.4.2 API level 19, so without wearable support) is asleep for most of the time, in which case I want it to wake up and stay awake until the task is completed.
What is the correct and best way to do this in Android, that is also relatively easy to test?
Thank you very much.
You need to use AlarmManager for cron tasks, this is a system service that can run at specified intervals, example of call:
Full docs about AlarmManager here.