I'm using an ad network to display some ads in my app. The loadAd
function from their library sometimes causes the emulator to freeze (maybe because of some firewall issues).
Anyway, I've since moved to using AsyncTasks
in which I do the actual call of that loadAd
method (so the UI doesn't freze anymore) which requests the banner or whatever from their servers.
Whenever I restart my Activity
, the onDetroy
method of the Activity
is called. In there, I call the AscynTask's
cancel
method so it will cancel the task and ... presumably stop/remove the thread.
Looking through the DDMS I'v noticed the below things:
See snapshot: http://bayimg.com/EAkBaAaEH
Every time I call the execute
method of the AsyncTask
, two AsynkTasks
(#1 and #2) are created which seem to not go away (be killed) when I call the cancel(true)
method in the `onDestroy().
After the Activity
restarts, another two AsyncTasks
threads are created (#3 and #4).
After another restart of the Activity
one more AsynkTask
is created (#5).
How can i actually kill the tasks? As in stop their execution entirely? Or do they actually stop and I'm just misinterpreting the DDMS?