Android Application kill, restart, restart, Method
1. Get the current process id and call the shell command to kill the process.
Int pid = android. OS. Process. myPid ();
String command = "kill-9" + Process. myPid ();
Try {
Runtime.getruntime(cmd.exe c (command );
} Catch (IOException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
}
2. Call the system method to kill the process,
Android. OS. Process. killProcess (android. OS. Process. myPid ());
3. Get the package name and restart the application
ActivityManager am = (ActivityManager) getSystemService (ACTIVITY_SERVICE );
Am. restartPackage ("com. android. nfc ");
4. Call the system interface to exit the application.
System. exit (0 );
5. Restart the activity of the application.
Intent k = mContext. getPackageManager ()
. GetLaunchIntentForPackage ("com. android. nfc ");
K. addFlags (Intent. FLAG_ACTIVITY_CLEAR_TOP );
MContext. startActivity (k );
6. Restart the application
ActivityManager am = (ActivityManager) mContext. getSystemService (mContext. ACTIVITY_SERVICE );
Am. restartPackage ("com. android. nfc ");