Your activity and all its views get recreated during the orientation
switch. Your handler is still trying to modify the old activity and
view. It also sounds like you're creating a new handler without
stopping the old one first, hence you end up with two of them running,
and therefore you get twice as many updates.


On Sun, Oct 25, 2009 at 5:10 AM, fhucho <fhu...@gmail.com> wrote:
>
> Hi,
> in my app I have a simple clock, the clock is updating every second. I
> update the clock using a handler -  to start ticking I call:
>
> handler.postAtTime(clockTask, currentTime + 1000);
>
> So after 1000 milliseconds clockTask is run. In clockTask I update the
> clock and call
> handler.postAtTime(clockTask, currentTime + 1000);  again.
>
> When my activity is restarted after orientation change and the clock
> was ticking, I start the clock in onCreate().
> But unfortunately the clock (which is a TextView) doesn't update!
> clockTask is run correctly every second, it tries to update the clock
> with correct time, but textViewClock.setText(time) doesn't have any
> effect. Just before textViewClock.setText(timeString) I print the
> timeString variable to logcat, and it is working ok. Now if I change
> screen orientation again, the clock still isn't updating but clockTask
> seems to be run twice every second (the previous clockTask is still
> running). If I now finish the activity the clockTask is still running
> twice every second.
> What can be behind this problem?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to