0

I am implementing Custom chrome tab in one of my app . I have initiated Custom chrome tab intent with startActivityforResult. When user back press from action bar or bottom menu activity's onActivityResult gets called but intent is null. I want to receive url as we do in onPageFinished(view, String url) in case of WebViewClient.

Thanks in advance .

Thanks in advance

SimpleCoder
  • 1,665
  • 1
  • 21
  • 34

1 Answers1

1

It is not possible to get the URL from the navigation callbacks in Custom Tabs. This is to protect the user privacy when navigating.

If you have control over the page that is being loaded, it would be possible to redirect the user to an URL using a Custom schema that is handled by your application, and pass the information you need in that URL.

If you do not control the page, the solution would be to provide a custom action button or use the bottom toolbar, that triggers a PendingIntent and starts your Activity. You would then use Activity.onNewIntent / Activity.getIntent to retrieve the URL, that will be available as the Intent data. This example shows how to do it with a BroadcastReceiver.

andreban
  • 4,621
  • 1
  • 20
  • 49