Created
October 15, 2015 09:36
-
-
Save junlincao/84d2226f946cabb86860 to your computer and use it in GitHub Desktop.
exit app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
startActivity(startMain); | |
System.exit(0); | |
} else {// android2.1 | |
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); | |
am.restartPackage(getPackageName()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment