- Either you implement booleans that can pause and then destroy the thread when your activity go throught the OnPause and OnDestroy methods.
- Either you use the method onRetainNonConfigurationInstance, but that is not enough, to avoid memory leaks, you also have to extend the class Runnable to inject two Booleans able to stop it.
Ah, yes, for more information, I posted some notes on my blog about this issue : http://android2ee.blogspot.com/ (those of the 15/12/2011 and the 21/11/2011). There is also an article (in french sorry about that) on developpez.com:Article on Handlers, AsyncTasks, Threads and memory leaks
I wish you a good download and a good understanding of the use of handlers.
These tutorials show how to use handlers.
Each tutorial is a zipped Eclipse project, directly importable into your workspace.
Download in a single file all these tutorials:
|Handler Tutorial with
This code is free for any usage but can't be distributed.
Its distirbution and its intelectual property belongs to the web site:
The use of those codes is under your own responsability and nobody (else than you) can be considered as responsible for any loss or damage of any nature that results from this usage.
All the quoted products name or marks of this books are trade marks by their respective owners.