I have two activities
MainActivity
DeepLinkActivity
I set up everything to use the NavUtils
for navi
It looks like NavUtils.shouldUpRecreateTask(this, upIntent)
is not prepared for this special case.
My current workaround is checking, if the Activity
was deep linked and force a new task stack for cases like this.
In my case, I pass around objects in EXTRA
s internally.
But an ACTION
and Uri
is set if the Activity
is started from outside by following a link to a specific URL or by touching NFC aware devices.
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent upIntent = NavUtils.getParentActivityIntent(this);
if (NavUtils.shouldUpRecreateTask(this, upIntent)
|| getIntent().getAction() != null) { // deep linked: force new stack
// create new task
TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent)
.startActivities();
} else {
// Stay in same task
NavUtils.navigateUpTo(this, upIntent);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}