switch statement - Switching activities back and forth in Android -
i'm starting on android , got beginner question on switching between multiple activities.
i understand can go between 2 activities invoking intent , returning setresult(). want know how jump between multiple activities. want learn process life-cycle. understand how every activity started ar oncreated(), i'm not sure how implement onresume() or onrestart() when want come back.
so have 3 activities: activity1, activity2 , anctivity3.
i start activity1 , invoke activity2 intent, , activity2 invokes activity3. using buttons. want come activity1 activity3. same thing here too. make intent , call startactivity(activity1_intent). gives runtime error.
i think need implement onresume() or onrestart(), i'm not sure how this. in oncreate() make gridview, when come back, need make gridview again?
if give small explanation of refer tutorial great. thank much.
in manifest file set android:launchmode="singletop" activity1.
then call activity1 use:
intent intent = new intent(this, activity1 .class); intent.addflags(intent.flag_activity_clear_top); intent.addflags(intent.flag_activity_new_task); startactivity(intent);
flag_activity_clear_top: if set, , activity being launched running in current task, instead of launching new instance of activity, of other activities on top of closed , intent delivered (now on top) old activity new intent.
flag_activity_new_task: if set, activity become start of new task on history stack.
http://developer.android.com/reference/android/content/intent.html
Comments
Post a Comment