Ives wrote:
> i uses the combination of Handler and Threads to fetch images for my
> app.
> 
> I wanted to know if I had create a inline thread:
> 
> class
> {
> public someMethods()
> {
> 
> final Handler h = ....;
> 
> Thread thread1 = new Thread()
> {
>       @Override
>       public void run()
>       {
>               // use Handler h to notify when complete
>       }
> };
> thread1.start();
> 
> }
> }
> 
> what happens if each of these method was called by the system:
> onPause, onStop, onDestroy
> 
> Am I correct to assume for onDestroy, a RuntimeException will be
> thrown as the object Handler h and whatever the Handler tries to
> access has already been cleared by the system.

Generally speaking, that is not correct. The Handler and its underlying
Activity are not "cleared by the system", because you still hold
references to them. The Activity will not be on the screen, and so
whatever you do will not be visible. And, it is conceivable that you
will do something that will cause a disconnected Activity to fail with
an Exception, but you should not be relying upon that behavior.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.1 Available!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to