Actually I have a direct issue with android custom tabs.
But nevertheless I will generalize my question. Let's assume that I have ActivityA
and ActivityB
. ActivityA
- is an external one, so that we launch it from an Intent :
Intent intent = customTabsIntent.intent;
intent.setData(requestUri);
intent.putExtra(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE, CustomTabsIntent.NO_TITLE);
mContext.startActivity(intent);
From here we see that ActivityA
- is actually a custom tab activity. When things get done I launch ActivityB
. I want ActivityA
dissaper from task history, I can achieve this by aplying flag Intent.FLAG_ACTIVITY_NO_HISTORY
to my intent. But this approach is causing problems, because when user switches to recents,or goes to other app - ActivityA
disappears forever. Of course - that's how flag no history works. But I want a different flow, I want ActivityA
disappear only when ActivityB
was launched. Any ideas how to achieve this?
P.S. I need to finish ActivityA
, which gets launched via intent, I don't have access to its code and I don't have the ability to call finish()
.
I don't think you can do this by using the NO_HISTORY flag since
ActivityA
is doing the launching and you have no control over it.However, you should be able to achieve your goal (not being able to go from
ActivityB
back toActivityA
by overriding the BACK button inActivityB
and having it go back to whatever is underneathActivityA
in the task stack.Assuming that
ActivityC
is the one that startsActivityA
, you could do something like this inActivityB
: