版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010872619/article/details/78493367
int currentVersion = android.os.Build.VERSION.SDK_INT;
if (currentVersion > android.os.Build.VERSION_CODES.ECLAIR_MR1) {
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mActivity.startActivity(startMain);
System.exit(0);
} else {// android2.1
ActivityManager am = (ActivityManager) mActivity.getSystemService(ACTIVITY_SERVICE);
am.restartPackage(mActivity.getPackageName());
}