views:

60

answers:

1

I'm interested in android activity lifecycle and I would like to get more detailed description/documentation/reference than widely available basic (onCreate->onStart->onResume) one.

My need comes from realizing that starting new activity (Theme.Dialog styled) from onAttachedToWindow() greatly improves response time if comparing to starting it from onCreate(). I wonder how this onAttachedToWindow() fits into whole android activity lifecycle. Official API ref description "Called when the window has been attached to the window manager" doesn't help a lot.

+1  A: 

My guess for why that feels more responsive, off the top of my head: I think that if you start Activity B from activity A's onCreate(), Activity A isn't drawn before activity B starts, which may take another second or two (making the app feel less responsive), where if you start activity B in Activity A's onAttachedToWindow(), A is started and rendered before B is kicked off, so the user doesn't have to sit for a second with a blank screen or the pre-A activity before seeing a reaction to their action.

Yoni Samlan
Your explanation does seem to correspond with what is happening, but I still don't get why doing *more work* (pre-A > A.onCreate(), A.onStart(), A.onResume(), A.onAttachedToWindow() > B) is faster than starting B from A.onCreate() (pre-A > A.onCreate() > B). Loading time from pre-A to B is <1s and ~7s respectively.
Ralkie