The first Activity of my app spawns a Thread to perform some IO operations. If in that moment the user hits the Back button the activity is destroyed (I can see the onDestroy method being called) but the Thread is still running (I can see it from the log messages).
If the user then comes back to the app the Activity is created again and in this moment I would like to check if the Thread is still running and, in this case, not start a new one.
Which is the best way to accomplish this?
Otherwise: is this bad design? Is it better to be sure that all threads started by the Activity are killed when onDestroy is called?
You could check your thread is alive on onDestroy
if it’s aLive can intrupt the thread when leaving activity