Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Callback on dismiss of chrome custom tabs

I have an activity 'A' and inside that activity, I have opened a chrome custom tab. Now when the user closes the chrome custom tab I want to open another activity 'B'. Is there a way to know when the chrome custom tabs has been closed. Or any other way to solve the above problem.

like image 608
rahulk9 Avatar asked Dec 07 '16 05:12

rahulk9


2 Answers

In Activity A you launch the Chrome Custom Tab like this:

private final int CHROME_CUSTOM_TAB_REQUEST_CODE = 100;

public void launchCustomTabs(String url) {
    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.intent.setData(Uri.parse(url));
    startActivityForResult(customTabsIntent.intent, CHROME_CUSTOM_TAB_REQUEST_CODE);
}

And in onActivityResult your check for that request code:

if (requestCode == CHROME_CUSTOM_TAB_REQUEST_CODE) {
    startActivity(this, ActivityB.class);
}
like image 78
Claus Holst Avatar answered Sep 17 '22 14:09

Claus Holst


well, this doesn't work, because it's not possible as per now to track the closing of chrome custom tab, if you are trying to call or display a dialog box on hit of back button, i.e., to ask for a confirmation. Well you can handle them over your activity (which is launching it at the first place) but that's not what you want i think. But if anyone does find the solution then please comment below.

like image 20
Siddharth Choudhary Avatar answered Sep 17 '22 14:09

Siddharth Choudhary