Last active
September 25, 2016 21:06
-
-
Save luckyhandler/fd4557c4e1ce132c962838c04e6789e5 to your computer and use it in GitHub Desktop.
Android - Soft restart
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
/** | |
* Initiates a soft application restart. | |
* Clears the UI stack and opens the the entry class giving the impression of a new application start | |
* @param context the context the activity should be started from | |
* @param activity the activity which is declared as main entry point for the app | |
*/ | |
public static void restartSoft(@Nonnull final Context context, @NonNull final Class<? extends Activity> activity) { | |
context.startActivity(new Intent(context, activity).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment