Sunday, October 2, 2011

Re: [android-developers] Activity gets (re)created when device goes to sleep?

it could be continue onResume()..You can logging it..

2011/10/2, Latimerius <l4t1m3r1us@googlemail.com>:
> Hello,
>
> I'm seeing something about the Activity life-cycle that I don't believe is
> covered in the Dev Guide section on Activities.
>
> I start an activity which causes its onCreate() and onResume() to be called:
>
> D/SkeletonActivity(19132): onCreate()
> D/SkeletonActivity(19132): onResume()
>
> The Activity is displayed, so far so good. Then I put the device to sleep
> and get this:
>
> D/SkeletonActivity(19132): onPause()
> D/SkeletonActivity(19132): onCreate()
> D/SkeletonActivity(19132): onResume()
> D/SkeletonActivity(19132): onPause()
>
> The Activity gets onPause() which is fine, but right after that it gets
> onCreate(), onResume() and onPause(). At this point the screen is blank so
> this seems a bit puzzling to me. Then I wake up the device but don't unlock
> it yet:
>
> D/SkeletonActivity(19132): onResume()
>
> The Activity is resumed, however no part of it is visible on screen. Then I
> unlock the device, finally actually returning to the Activity:
>
> D/SkeletonActivity(19132): onPause()
> D/SkeletonActivity(19132): onCreate()
> D/SkeletonActivity(19132): onResume()
>
> The Activity instance created after the device was put to sleep is paused
> (and presumably destroyed?) and onCreate()/onResume() is called just like it
> would for a new Activity instance.
>
> There must be something I'm missing about the Activity life cycle. What I
> would expect would be simply onPause() when the device goes to sleep and
> onResume() after it's woken up *and* unlocked.
>
> I'm testing this with a slightly modified SkeletonActivity sample (just
> added logging and overrode onPause() to enable logging). The behaviour
> seems to be the same or equivalent on HTC Desire (2.1), LG Optimus One (2.2)
> and Samsung Galaxy Tab (2.2).
>
> Does anybody know what's going on there?
>
> Cheers!
>
> --
> 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+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment