ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
activityManager.killBackgroundProcesses(getPackageName()); //关闭了所有Activity
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
在AndroidManifest.xml 加上
<!-- 关闭进程 --><uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>