Last active
August 29, 2015 14:22
-
-
Save atoennis/4f43ef75a1068c8a253a to your computer and use it in GitHub Desktop.
Need to navigate to multiple levels deep in your hierarchy but need to preserve navigation? This is a common scenario for tapping on a notification. Doing multiple startActivity() calls in a row can make for some sloppy code. Enter TaskStackBuilder, a clear and concise way to manage your back stack!
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
<!-- Setting the parentActivityName can help the TaskStackBuilder build out the back stack | |
if methods like .addNextIntentWithParentStack(Intent intent) are used --> | |
<activity | |
android:name=".ui.home.HomeActivity" | |
android:launchMode="singleTop" | |
android:label="@string/app_name"/> | |
<activity | |
android:name=".ui.upload.UploadActivity" | |
android:parentActivityName=".ui.home.HomeActivity" | |
android:launchMode="singleTop" | |
android:label="@string/app_name"/> | |
<activity | |
android:name=".ui.upload.UploadDetailActivity" | |
android:label="@string/app_name" | |
android:parentActivityName=".ui.upload.UploadActivity"/> |
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
// http://developer.android.com/reference/android/support/v4/app/TaskStackBuilder.html | |
TaskStackBuilder.create(this) | |
.addNextIntent(HomeActivity.buildIntent(this, domainObject)) | |
.addNextIntent(UploadActivity.buildIntent(this)) | |
.addNextIntent(UploadDetailActivity.buildIntent(this, anotherDomainObject)) | |
.startActivities(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment