Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Close Button for Chrome Custom Tab

Is it possible to override the behaviour of the default close button on custom chrome tabs in Android? For example instead of just closing the chrome tab, can we redirect to a new Activity, or launch a dialog?

like image 218
Mood Avatar asked Oct 26 '25 06:10

Mood


1 Answers

I'm not sure if you can do that. You can try to start the CustomTabIntent for result and wait for it finish and start it from onActivityResult() based on the requestCode you have started it with.

  private void openUrlForResult(CustomTabsIntent customTabsIntent, String url, int requestCode){
        customTabsIntent.intent.setData(Uri.parse(url));
        startActivityForResult(customTabsIntent.intent, requestCode);
    }
like image 58
Nikola Despotoski Avatar answered Oct 28 '25 20:10

Nikola Despotoski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!