When navigating up my parent activity requires some extras. But I'm not sure how can I supply it. AppCompatActivity's documentation states:
If any activity * along the parent chain requires extra Intent arguments, the Activity subclass * should override the method {@link #onPrepareSupportNavigateUpTaskStack(android.support.v4.app.TaskStackBuilder)} * to supply those arguments.
That's what I have so far.
AndroidManifest.xml
<activity
android:name=".user.offers.detail.OfferDetailActivity"
android:theme="@style/AppTheme.NoActionBar"
android:parentActivityName=".user.offers.master.OffersMasterActivity"
android:screenOrientation="portrait">
</activity>
There's not much information on how to override onPrepareSupportNavigateUp, so here's my best guess (in 'child' activity):
override fun onPrepareSupportNavigateUpTaskStack(builder: TaskStackBuilder) {
builder.editIntentAt(builder.intentCount - 1)?.apply {
putExtra(OffersMasterActivity.CAT_KEY_EXTRA, catKey)
putExtra(OffersMasterActivity.CAT_NAME_EXTRA, catName)
putExtra(OffersMasterActivity.CAT_PICPATH_EXTRA, picPath)
}
}
But the method is never called to figure out if my implementation valid.
Any help would be greatly appreciated!
For
onPrepareSupportNavigateUpto be called,supportShouldUpRecreateTaskshould be overridden first returningtrue.