Several methods of Android killing process are introduced in detail

Android kill process:

For the end of the process, it is still necessary to develop app applications. Here are three methods that you can choose according to your needs.

When the application is no longer used, it is usually necessary to close the application. You can close the Android Application in the following three ways:

The first method: first get the ID of the current process, and then kill the process.

android. os. Process. killProcess(android.os.Process.myPid())

Next, practice:

Add click event code

Before clicking the button, you can see the process

After clicking the button, the process will commit suicide

The second method: terminate the currently running Java virtual machine, causing the program to terminate

System. exit(0);

android. permission. KILL_ BACKGROUND_ PROCESSES

The third method: force all execution associated with the package to be closed

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>