Skip to content

Instantly share code, notes, and snippets.

@luckyhandler
Last active September 25, 2016 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luckyhandler/fd4557c4e1ce132c962838c04e6789e5 to your computer and use it in GitHub Desktop.
Save luckyhandler/fd4557c4e1ce132c962838c04e6789e5 to your computer and use it in GitHub Desktop.
Android - Soft restart
/**
* 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