[android-developers] Can startActivity() be called from any of the Activity lifecycle methods?
Of the lifecycle methods, like onCreate(), onStart(), onResume(), can
startActivity() be called from inside those methods? If not, what
would happen if you tried it? If so, how would calling
startActivity() affect the current Activity's lifecycle? If you call
startActivity() from onStart(), for example, before an Activity is
displayed to the user, does the current Activity skip right to
onStop(), before showing the new Activity, or would it's normal
lifecycle happen (onResume(), onPause(), onStop(), then new activity)?
I would like to ask the same question of finish(). Can finish() be
called from inside any/all of the Activity lifecycle methods? The
documentation refers to calling finish() from onCreate(), where it
talks about the normal lifecycle being interrupted as a special case:
"You can call finish() from within this function, in which case
onDestroy() will be immediately called without any of the rest of the
activity lifecycle (onStart(), onResume(), onPause(), etc) executing.'
I'm just curious what happens in these special cases, and whether
there are any caveats to calling these methods in these areas.
One reason I ask is because I am trying to figure out the best way to
present a login panel (either a dialog or a LoginActivity) to the user
whenever any of my Activities are entered into, but the system hasn't
yet logged the user onto the server. There are probably countless
ways to achieve this functionality, and I'm trying to determine the
most recommended way.
--
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home