6

In my use case, I have a page that deep links back to my app. When I open this page in Chrome custom tab, I am able to get back to my app by clicking the deep link but the issue is when I click on the device back button, the chrome tab is still visible.

Is there any way I can close the chrome custom tab when the user is back to my app/activity.

Arun
  • 191
  • 1
  • 7

2 Answers2

13

Setting the below flag while opening chrome custom tab seems to resolve the issue for me http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NO_HISTORY

Arun
  • 191
  • 1
  • 7
  • 3
    I came across the same issue. As per your answer I am adding the flag as: `mCustomTabsIntent = new CustomTabsIntent.Builder(mCustomTabsSession).build(); mCustomTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);` before launching the custom tabs. but its not solving issue. Is there something which I am missing? – Jaspinder Kaur Dec 01 '16 at 11:51
  • 1
    not working for me either? Any one else have any luck with this? – Vardaan Sharma Apr 21 '17 at 13:28
  • @arun, My chrome tab disappears when I press home button and come back to screen. – Rishabh Saxena Apr 23 '20 at 05:31
2

As @Jaspinder Kaur mentioned: you need to add this on your flag:

mCustomTabsIntent = new CustomTabsIntent.Builder().build(); 
mCustomTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_NO_HI‌​STORY)

AND:

If you set your app to be singleInstance or singleTop, then when you go back to it using an intent, the framework will finish Custom tab activity as well.

Paula Kristin
  • 813
  • 2
  • 11
  • 27