开发者

Android webview links open in default browser

开发者 https://www.devze.com 2023-02-21 04:05 出处:网络
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 w

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)));

0

精彩评论

暂无评论...
验证码 换一张
取 消