1: 殺死自己進程的方法
android.os.Process.killProcess(Process.myPid());
2:殺死別人進程的方法(不能殺死自己)
-------a: activityManager.killBackgroundProcesses
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
activityManager.killBackgroundProcesses("com.android.mms");
需要加入權限:
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
--------b :activityManager.restartPackage("com.diandian");
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
activityManager.restartPackage("com.diandian");
需要加入權限
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>