3
votes

I have a scenario where links in my webview should open the default android browser. I searched regarding this and I got to know that if we are setting the custom webviewclient in our webview and load the url in shouldOverrideUrlLoading method, then it will not work. But in my case, I need to extend the WebviewClient in the webview since I am doing some cookie management and loading some javascript code. May I know how I can use both functionalities together?

1

1 Answers

0
votes

If you set a WebViewClient to your webView you can use it's onPageStarted or onPageFinished methods to perform the actions that you want. Both methods receive the url as a parameter, so this allows you to send this url to the default android webbrowser.

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));