I want to click a button in an android application to kill all services and activities and launch the entire application. I tried the following two codes. After execution, it can be launched, but some mobile phones prompt that it is abnormal. The "App has stopped running" prompt is launched.
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
How to write?
Just manage the Activity stack well
There is no need to use this forced exit method android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
How to terminate the background service correctly
You can refer to how to exit the service, and call stopService where needed