gpt4 book ai didi

android - Webview 不加载特定网站

转载 作者:太空宇宙 更新时间:2023-11-03 12:45:24 24 4
gpt4 key购买 nike

我有一个 Webview,我试图在其中加载 this url

但是 webview 是空白的,我在 list 中添加了 internet 权限,尝试在同一个 webview 中加载 google.com,它加载正常。

尝试在手机浏览器(chrome)中加载相同的 url,它加载正常

这是我的代码:

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webviewmain);
mWebView.setWebViewClient(new WebClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(url);
}
private class WebClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}

@Override
public void onPageFinished(WebView view, String url) {

}
}

日志:

I/chromium: [INFO:CONSOLE(1)] "Angular is running in the development mode. Call enableProdMode() to enable the production mode.", source: https://www.xfinityprepaid.net/CustomerActivation/vendor.23a90aa3d57e711f4e5c.bundle.js (1)
I/chromium: [INFO:CONSOLE(1)] "ERROR", source: https://www.xfinityprepaid.net/CustomerActivation/vendor.23a90aa3d57e711f4e5c.bundle.js (1)file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:186;Function:ASN1_get_object


D/libc-netbsd: getaddrinfo: adservice.google.co.in get result from proxy gai_error = 0
D/libc-netbsd: getaddrinfo: match.adsrvr.org get result from proxy gai_error = 0
D/OpenSSLLib: OpensslErr:Module:12(116:176); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:186;Function:ASN1_get_object
D/OpenSSLLib: OpensslErr:Module:12(116:176); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:186;Function:ASN1_get_object
D/libc-netbsd: getaddrinfo: www.facebook.com get result from proxy gai_error = 0
D/OpenSSLLib: OpensslErr:Module:12(116:176); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:186;Function:ASN1_get_object
D/OpenSSLLib: OpensslErr:Module:12(116:176); file:external/boringssl/src/crypto/asn1/asn1_lib.c ;Line:186;Function:ASN1_get_object
D/libc-netbsd: [getaddrinfo]: mtk hostname=www.xfinityprepaid.net; servname=(null); netid=0; mark=0

这个问题有什么解决办法吗?

最佳答案

我遇到了类似的问题。经过长时间的研究,我添加了很多代码,它开始工作了。这不是正确的答案,但我的 Angular 网站开始着手添加这段代码。检查一下,如果有帮助请告诉我。

    webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowContentAccess(true);

webView.loadUrl(url);

webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setDomStorageEnabled(true);
webView.clearView();
webView.setHorizontalScrollBarEnabled(false);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
webView.getSettings().setDatabasePath("/data/data/" + this.getPackageName() + "/databases/");
}
webView.setVerticalScrollBarEnabled(false);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setPluginState(WebSettings.PluginState.OFF);
webView.setScrollbarFadingEnabled(false);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webView.setInitialScale(1);

webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.loadUrl(request.getUrl().toString());
}
return false;
}
});

关于android - Webview 不加载特定网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47367382/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com