Start Activity 2 Start Activity 3 Navigate back Foreground activity Activity 3 Activity 1 Activity 2 Activity 3 Activity 2 Back Stack Activity 1 Activity 2 Activity 1 Activity 3 Activity 1 destroyed When the user presses the 12:45 Back button,the current activity is popped from the top of the stack and the previous activity resumes Refer to: http://developer.android.com/guide/components/tasks-and-back-stack.html
6 • When the user presses the Back button, the current activity is popped from the top of the stack and the previous activity resumes Refer to: http://developer.android.com/guide/components/tasks-and-back-stack.html
task A User selects to view Activity 2 the second scene User get back to Main Menu the main menu User selects to view the first scene Activity 1 Separate instance User launches Main Menu the app A single activity is instantiated multiple times
7 A single activity is instantiated multiple times. Main Menu Activity 1 Main Menu Activity 2 Separate instance task User launches the app User selects to view the first scene User get back to the main menu User selects to view the second scene
Launch Modes of Activity The launchMode attribute specifies an instruction on how the activity should be launched into a task There are four different launch modes you can assign to the launchMode attribute o standard:(the default mode) o singleTop:Reuse the activity on the top o singleTask:The system creates a new task and instantiates the activity at the root of the new task. o singleInstance Refer to: http://developer.android.com/quide/components/tasks-and-back-stack.html http://inthecheesefactory.com/blog/understand-android-activity-launchmode/en 8
Launch Modes of Activity • The launchMode attribute specifies an instruction on how the activity should be launched into a task • There are four different launch modes you can assign to the launchMode attribute o standard: (the default mode) o singleTop: Reuse the activity on the top o singleTask:The system creates a new task and instantiates the activity at the root of the new task. o singleInstance 8 Refer to: http://developer.android.com/guide/components/tasks-and-back-stack.html http://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
Launch Modes of Activity <activity android:name=".NewsDetailActivity"android:launchMode="singleTop"> <intent-filter> <action android:name="android.intent.action.VIEW"></action> <category android:name="android.intent.category.DEFAULT"></category> <category android:name="android.intent.category.BROWSABLE"></category> <data android:scheme="oauth"android:host="twitt"></data> </intent-filter> </activity> http://ww.intridea.com/blog/2011/6/16/android-understanding-activity-launchmode 9
Launch Modes of Activity 9 <activity android:name=".NewsDetailActivity" android:launchMode="singleTop"> <intent-filter> <action android:name="android.intent.action.VIEW"></action> <category android:name="android.intent.category.DEFAULT"></category> <category android:name="android.intent.category.BROWSABLE"></category> <data android:scheme="oauth" android:host="twitt"></data> </intent-filter> </activity> http://www.intridea.com/blog/2011/6/16/android-understanding-activity-launchmode
Pass Data using Intent 10
Pass Data using Intent 10