I have the solution :)

I use the same handler (set as static variable), so i don't lose the
reference.

Then I have made myHandler that extends Handler where i have a
reference to the active activity, so when i rotate screen
active_activity == null in onStop() and when start the onCreate() a
update the reference in the Handler active_activity = this

it works! :D

On 25 Feb, 13:37, skink <[email protected]> wrote:
> On Feb 25, 1:03 pm, Paolo <[email protected]> wrote:
>
>
>
>
>
> > Do nothing.
> > my background thread has a reference to the (first) handler. when it
> > finishes it sends a message on this handler.
>
> > If I rotate the screen before the thread has sent the message, i think
> > that my activity is able to catch the message because I read this from
> > the Documentation:
>
> > "A Handler allows you to send and process Message and Runnable objects
> > associated with a thread's MessageQueue. Each Handler instance is
> > associated with a single thread and that thread's message queue. When
> > you create a new Handler, it is bound to the thread / message queue of
> > the thread that is creating it -- from that point on, it will deliver
> > messages and runnables to that message queue and execute them as they
> > come out of the message queue."
>
> > is it correct my idea?
>
> > On 25 Feb, 12:46, skink <[email protected]> wrote:
>
> > > Paolo wrote:
> > > > Hi,
>
> > > > In my main activity (ListActivity) i start a thread in background to
> > > > do some work and always in the activity i use a Handler to receive a
> > > > message, containing in the filed obj one vector with many objects,
> > > > from the thread when it finishes its work. Obviously i have overridden
> > > > the methods handleMessage(Message m).
> > > > It seems to work fine if I don't rotate the screen.
>
> > > > I would like to know what happen to the handler if i rotate the screen
> > > > (like in the G1 using keybord). I know the the activity is destroyed
> > > > with onDestroy and created again with onCreate(). and my handler? what
> > > > happen to my handler?
>
> > > handler is just handler (new one is created), the real question is
> > > what you do with your thread if you rotate the screen
>
> > > pskink
>
> if you do nothing with your thread i think that you should use in that
> thread new handler, old one is associated with old activity
>
> pskink

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to