In the Android development process, especially when the interface is more than the case, with the usual exit method is often not completely quit the application, the network is also a lot of various exit programs. One of them should be used by the majority of developers, but also very clear and convenient, is to maintain a single list<activity> management container in application, each time the new activity is opened to add the current activity to the container, Then, when a full exit is required, the loop traverses the container to finish () each activity, i.e. the full exit function is reached.
Although this exit is very good, but there is a hidden memory leak, so we need to find a better solution. Here's a very good, super-simple way to do this, without having to manage the activity, but by doing it in the activity's startup mode.
Give me an example!
For example: There is an application that opens first into the A Interface (boot interface), then into the B interface (main interface), then into the C interface, into the D interface, into the E interface, into the F interface, then back to the B interface (main interface), then into the G interface, into the H interface, and finally back to the B interface a->b->c->d->e->f->b->g->h->b. If the activity is in the default startup mode, then the Exit button on the main interface B to exit the entire app, you need to turn off the B-h-g-b-f-e-d-c-b-a interface, then the egg ... No one wants to shut it off like this. But if we set the B interface (main interface): Android:launchmode= "Singletask", then the boot process from a->b->c->d->e->f->b to the B interface, Instead of recreating a B interface, you will automatically finish off the C, D, E, f interfaces and then use the original B interface. And then from the b->g->h->b, it will automatically finish off the G, H interface and before using the B interface. So, quit the entire app also just quit interface A and interface B, and a interface is the boot interface, when you go from a to B you can finish off a, however, now only need to finish their own on the main interface B can be.
Get out of the app app with a touch of relaxation!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Elegant app exit scenario completely (no hidden memory leaks)