I. Relationship between activity and task (stack)
Task is like a container, and activity is equivalent to filling in the container. The first thing (activity) will be at the bottom, and the last added thing (activity) it will be at the lowest end. Retrieving an activity from a task is taken from the top, that is, the last added activity is retrieved first, and so on. The last added activity is retrieved, the sequence of the activity in the task can be controlled, so intent flag is used in the activity jump.
2. Intent is used for page Jump and service start. Intent flag is about activity jump.
Intent intent = new intent (this, XXX. Class );
// If the activity exists in the task, it gets to the top and does not start a new activity.
Intent. addflags (intent. flag_activity_brought_to_front );
// If the activity exists in the task, terminate all the activities on the activity.
Intent. addflags (intent. flag_activity_clear_top );
// The default redirect type. Place the activity in a new task.
Intent. addflags (intent. flag_activity_new_task );
// If the activity has been run to a task, the activity will not be running again
Intent. addflags (intent. flag_activity_single_top );