Yet Another Dev Blog

Scheduling repetitive task on Android

There is a task that needs to be repeated every N seconds. Might be even an interview question to see what options person would consider. With no other requirements or restrictions given, here is what pops up in my mind:

Fragments. Retaining state and objects.

There is a lot of good stuff written already about Activity and Fragment lifecycle and how to manage state and object retaining properly. So following is just a recap for future myself, rather than a tutorial.

Let's take a look at Activities and their destiny. There are 3 cases when and how activity can be destroyed.