2011-11-02 | 03:45 PM - 04:35 PM |
Android Activities can possess one of four launch modes and one of many activity tasks. We will explore how your choices of launch modes and tasks affect your Applications back stack history and what will happen behind the scenes. After this talk you will confidently be able to wield the best launch modes for your apps activities in every situation!
34. How can we choose a specific task behaviour for our activities?
35. Activity launch modes Define how a new instance of an activity is associated with the current task
36.
37. Defined in the manifest < activity android:launchMode = "singleTop" android:name = ".HelloWorldActivity" />
38. Set as a flag in an intent Intent intent = new Intent( this , HelloWorldActivity. class ); intent.addFlags(Intent. FLAG_ACTIVITY_SINGLE_TOP ); startActivity(intent);
41. singleTop A new activity X will not be started if there is an activity X on top of the stack onNewIntent() will be called instead of the normal activity lifecycle
42. singleTask Created at the root of a new task Only one instance of the activity can exist at a time onNewIntent() is called if an instance of the activity already exists