When you do an Android project, you find a problem: When the application exits, click "Settings" to view the application, and the interface shows you can click "Force off".
I think the reason for this is that there are still open activity not being destroy, and then do the debugging, and then find that the activity should be all
Destroy. But the result is that you can click "Force off".
As a result of this problem I found a more serious problem, that is, after my application quit, the system did not release my application memory.
Then look up the solution on the Internet. said there are two:
Mode one:
Intent Intent = new Intent (intent.action_main);
Intent.addcategory (Intent.category_home);
Intent.setflags (Intent.flag_activity_new_task);
This.startactivity (Intent);
System.exit (0);
Mode two:
Android.os.Process.killProcess (Android.os.Process.myPid ());
------------------------------------------------------------------------------------------------------------ ----------------------------------------------------------
Some people say you can end the application, but for some reason, After I tried these two methods, I still couldn't end my application.
When I click "Settings" to see my application, the interface still shows that you can click "Force off".
However, you can use both methods to free up memory for your application.
A serious problem has been solved, and the question that you can click "Force shutdown" does not seem to have any effect. So I didn't solve the problem.
finally say the two ways and where to use it.
The first way is to quit the virtual machine, and in this way, it should be noted that if the device has two or more application-category for home
applications, the device will let the user choose which application to go to when exiting the application.
The second way is to kill the current application process. It does not happen to allow the user to choose which application to go into.
where it is used, it is generally used in the OnDestroy () method of the last activity
@Override
protected void OnDestroy () {
//TODO auto-generated method Stub
Super.ondestroy ();
//Release application ' s RAM
Intent Intent = new Intent (intent.a Ction_main);
Intent.addcategory (intent.category_home);
Intent.setflags (Intent.flag_activity_new_task);
This.startactivity (Intent);
System.exit (0);
}