无法在“应覆盖的Web视图"中获取网址
问题描述:
我正在开发一个具有Webview的android应用.
I am developing an android app, which has a webview in it..
在帖子中单击该帖子时,URL为 https://www.facebook.com/. webview的帖子URL不能进入,但应覆盖url,但webview会将Facebook重定向到该特定帖子,这是webviewclient的shouldoverriding方法中的url应该存在的问题
The URL is https://www.facebook.com/ when the post is clicked in the webview the post URL is not getting in should overidding url but webview is redirecting the facebook to that particular post what is the problem the url should be in the shouldoverriding method of the webviewclient
Here I am Setting the Custom WebView Client
webView.setWebViewClient(new WebViewController());
public class WebViewController extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
Log.e("urltop", str + " ==top");
String str3 = "youtube";
if (!str.contains("market://")) {
if (!str.contains("mailto:") && !str.contains("play.google") && !str.contains("tel:") && !str.contains("intent:") && !str.contains("vid:") && !str.contains(str3) && !str.contains("fb-messenger://")) {
if (!str.contains("whatsapp://")) {
if (str.contains("m.me")) {
Log.e("urlm.me", str);
return true;
} else if (str.contains("jpg")) {
Log.e("urljpg", str);
return true;
}
return true;
} else {
Log.e("url", str);
}
}
}
return true;
}
先谢谢您了:)
答
只需使用shouldOverrideUrlLoading
:
public class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.equals("YOURLINK")) {
Intent intent = new Intent(getContext(), YourActivity.class);
startActivity(intent);
return true; // Handle By application itself
} else {
view.loadUrl(url);
return true;
}
}
}