Created
September 22, 2016 09:30
-
-
Save amatkivskiy/1bb5e05fcf08eb5c2cc80f2bab08b6e9 to your computer and use it in GitHub Desktop.
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
// Check whether back stack exists. | |
if (Referrers.hasReferrer(getIntent())) { | |
// If the current back stack exists just navigate to parent activity. | |
Class parentActivityClass = Referrers.getReferrer(getIntent()); | |
Intent intent = new Intent(this, parentActivityClass).setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP); | |
this.startActivity(intent); | |
} else { | |
// If ItemDetailsActivity was open for example from the notification then create back stack manually. | |
Intent collectionsIntent = ContentCollectionActivity.createIntent(this, null); | |
Intent mainActivityIntent = new Intent(this, MainActivity.class); | |
TaskStackBuilder.create(this) | |
.addNextIntent(mainActivityIntent) | |
.addNextIntent(collectionsIntent) | |
.startActivities(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment