We exit the activity can be called: Finish (), System (0), but these are simply quitting a single activity
Some people will say that directly kill the process, these practices are not very desirable, in fact, we look at the API can be found that the Activity
Are all put into the stack management, we just have to empty the stack, not completely out of it. To the stack of activity
Management, you need to understand the four states of Launchmode, here is not much to say, look at the API.
We use android:launchmode= "Singletop", when the activity is on top of the stack, it empties the activity underneath it.
Then finish off the current activity and close it completely.
Instance a,b,c,d four Activity;a as a portal, set android:launchmode= "Singletop" in Manifest.xml
Several others do not need to be set. Boot order A->b->c->d
Here we add the flag intent.flag_activity_clear_top in intent when we open the A window in the D window.
When you turn on a again, all activity for that process space will be cleared.
Use the following code in D:
Intent Intent = new Intent ();
Intent.setclass (D.this, A.class);
Intent.setflags (Intent.flag_activity_clear_top); Note the flag setting of the bank
StartActivity (Intent)
Finish ();
A In the code:
protected void Onnewintent (Intent Intent) {super.onnewintent (Intent);//Exit if (Intent.flag_activity_clear_top & Intent.getflags ())! = 0) {finish ();}}
Because A is android:launchmode= "singletop" does not call OnCreate (), but responds Onnewintent ()
At this time Judge Intent.flag_activity_clear_top, then put a finish () off.
B,c was also cleared, because A is android:launchmode= "Singletop", and the stacks below are cleared.
All a,b,c,d in the stack are cleaned up. So the whole program exited.