Intent.flag_activity_clear_top for Android

If set, and the Activity is already running in the current Task, so instead of restarting an instance of the Activity, Instead, all activities above the Activity are closed and the Intent is delivered to the old Activity (now at the top) as a new Intent. For example, suppose A Task contains these activities: A, B, C, D. If D calls startActivity() and contains an Intent to ActivityB, C and D both end, and B receives the Intent, so the stack is now A, B. The Activity B running in the above example can either receive the new Intent in onNewIntent() or shut itself down and restart to receive the Intent. If its launch mode is declared "multiple" (the default) and you don't set FLAG_ACTIVITY_SINGLE_TOP in the Intent, it will close and re-create. For other launch modes, or by setting FLAG_ACTIVITY_SINGLE_TOP in the Intent, The launch mode can also be used in conjunction with FLAG_ACTIVITY_NEW_TASK to start the root Activity in a Task, which brings to the foreground any running instances of that Task. Then clear it up to the root Activity. This is useful, for example, when an Activity is started from the Notification Manager.Copy the code
With the Intent FLAG_ACTIVITY_CLEAR_TOP, the first B and the second A, Destory drops but the destories of B and A are not called when b-a-C jumpsCopy the code
  • The target for this Intent is FLAG_ACTIVITY_CLEAR_TOP, which means that if the Activity object exists in the Activity stack, the object is not created, and all activities on the object are terminated and returned to the Activity
  • This condition is not satisfied when A jumps C above. Of course, if you want to achieve this effect can be used: it. SetFlags (Intent. FLAG_ACTIVITY_NEW_TASK | Intent. FLAG_ACTIVITY_CLEAR_TASK);
Share with you

I want to work my way up

Fly forward on the blades at the highest point

Let the wind blow dry tears and sweat

I want to work my way up

Waiting for the sun to watch its face

Little days have big dreams

I have my day

Let the wind blow dry tears and sweat

One day I will have my day