【发布时间】:2016-03-19 21:11:51
【问题描述】:
我正在尝试在 Android 中使用 Webview 打开链接。 WebView 中嵌入了一些链接。我的问题是 webview 没有打开任何不以 www 开头的链接。例如,www.google.com 正在工作,但 maps.google.com 没有。我也尝试过覆盖 WebViewClient 但它没有工作。 我注意到的一件事是通过 Toast 查看 WebViewClient 中调用的 url。它对 www.google.com 显示完美,但对其他链接没有返回任何内容。在这种情况下,我认为 WebViewClient 不会被覆盖。可能是什么原因。我是否必须调用 webview 的任何方法或某些属性。 任何帮助将不胜感激。
menuView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
super.shouldOverrideUrlLoading(view, url);
Toast.makeText(getApplicationContext(), "url:--" + url, Toast.LENGTH_LONG).show();
view.loadUrl(url);
return false;
}
});
我已经设置的属性是:
menuView.setVerticalScrollBarEnabled(false);
menuView.setHorizontalScrollBarEnabled(false);
final WebSettings webSettings = menuView.getSettings();
menuView.getSettings().setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setSupportMultipleWindows(true);
webSettings.setPluginState(PluginState.ON);
webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
menuView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
menuView.getSettings().setBuiltInZoomControls(true);
// Below required for geolocation
menuView.getSettings().setJavaScriptEnabled(true);
menuView.getSettings().setGeolocationEnabled(true);
webSettings.setGeolocationEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
【问题讨论】:
-
张贴您的任何代码 sn-p 将不胜感激
-
使用带有 https:// 的完整网址,例如 webview.loadUrl("maps.google.com");
-
链接在已加载的网页中给出。 @koutok
-
发布网址未加载
-
ok 让我检查一下...
标签: android webview android-webview google-maps-api-2