How Can I Load A Link In Other Browser From Web View?
I am loading string value in my web view and i need when i click on the link shown in web view should open in other web browser of phone. I want like this - String s = 'hello read
Solution 1:
Try this:
webView.setWebViewClient(new WebViewClient(){
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) {
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
} else {
return false;
}
}
});
Solution 2:
You can do something like this:
String s = "<a href='http://www.google.com' target='_blank'>Read more over here</a>";
webview.loaddata(s);
You will need to add other html content by yourself.
So basically, you can use target='_blank'
which will open it in a new browser, not in webview.
Hope it helps.
Post a Comment for "How Can I Load A Link In Other Browser From Web View?"