I have a scenario where links in my webview should open the default andr开发者_JAVA百科oid 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?
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)));
精彩评论