Chrome custom tabs activity result

3.5k Views Asked by At

I'm launching Chrome Custom Tabs using a similar function as below but I'm always getting the activity result as canceled which makes sense when clicking the close icon. but isn't really helping when I want to differentiate between a redirection to the app and the close icon click. is there a way to set the activity result for the custom tabs?

   fun launchURL(context: Context, url: String, requestCode: Int) {
       val builder = CustomTabsIntent.Builder()
       val customTabsIntent = builder.build()
       customTabsIntent.intent.data = Uri.parse(url)
       (context as Activity).startActivityForResult(customTabsIntent.intent, requestCode)
}
1

There are 1 best solutions below

2
Jakoss On

AFAIK you cannot listen for specific url running in custom tab, so the only way you can handle the redirection to the app is to handle a deeplink. When user clicks the deeplink in the custom tab it will be treated like a normal deeplink in the system. If your app is registered to handle it - it will.