I decided to answer my question, as I learned how to do it right. Android way. First of all, what I am trying to do and published in this question is the wrong approach to my requirement. Now I am publishing this so that someone else does not do it wrong, but as follows.
Android has several synchronization options.
Timer-task → works while the application is running. best suited for short term. Resource utilization above.
The handler → works while the application is running. But not suitable for use as a planner. (this is what I requested, and this is not the right way to do this). Handlers are the best way to do something repeatedly until the application is killed.
- Alarm-manager → The best way to plan something in the future, even if the application is killed. (this is what I have to apply for my application).
Here is what I understood. Correct me if I am wrong.
source share