Skip to content

Instantly share code, notes, and snippets.

@mortenjust
Created September 9, 2015 02:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mortenjust/68366642934e6dbeb7c0 to your computer and use it in GitHub Desktop.
Save mortenjust/68366642934e6dbeb7c0 to your computer and use it in GitHub Desktop.
Start an activity without back stack and kill current activity
Intent i = new Intent(this, WatchFaceActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
finish();
@six519
Copy link

six519 commented Aug 16, 2022

For Kotlin:

        val i: Intent = Intent(this, WatchFaceActivity::class.java)
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
        startActivity(i)
        finish()

@Paphra
Copy link

Paphra commented Mar 30, 2023

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment