在API 21及更高版本中,Android Webview加载失败

在API 21及更高版本中,Android Webview加载失败,第1张

概述我有一个使用WebView并加载页面的Android应用程序.此应用程序可在运行API16或更高版本的Android设备上运行.AndroidWebView代码:StringURL="https://sandbox.napas.com.vn/gateway/message";@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.on

我有一个使用WebVIEw并加载页面的Android应用程序.此应用程序可在运行API 16或更高版本的AndroID设备上运行.

AndroID WebVIEw代码:

String URL = "https://sandBox.napas.com.vn/gateway/message";@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentVIEw(R.layout.activity_web_vIEw);    webvIEw = (WebVIEw) findVIEwByID(R.ID.webvIEw);    webvIEw.getSettings().setJavaScriptEnabled(true);    webvIEw.getSettings().setAllowfileAccess(true);    webvIEw.getSettings().setPluginState(PluginState.ON);    webvIEw.getSettings().setDomStorageEnabled(true);    webvIEw.getSettings().setAllowContentAccess(true);    webvIEw.getSettings().setAllowfileAccessFromfileURLs(true);    webvIEw.getSettings().setJavaScriptCanopenwindowsautomatically(true);    webvIEw.setWebChromeClIEnt(new MyWebChromeClIEnt());    webvIEw.loadUrl(URL);    webvIEw.setWebVIEwClIEnt(new WebVIEwClIEnt() {        @OverrIDe        public boolean shouldOverrIDeUrlLoading(WebVIEw vIEw, String url) {            vIEw.loadUrl(url);            return true;        }        @OverrIDe        public voID onPageStarted(WebVIEw vIEw, String url, Bitmap favicon) {            super.onPageStarted(vIEw, url, favicon);        }        @OverrIDe        public voID onPageFinished(WebVIEw vIEw, String url) {            super.onPageFinished(vIEw, url);        }    });}

但是webvIEw加载页面为空,并且有日志:

E/libEGL(25467): valIDate_display:255 error 3008 (EGL_BAD_disPLAY)W/AudioCapabilitIEs(25467): Unsupported mime audio/evrcW/AudioCapabilitIEs(25467): Unsupported mime audio/qcelpW/VIDeoCapabilitIEs(25467): Unrecognized profile 2130706433 for vIDeo/avcW/AudioCapabilitIEs(25467): Unsupported mime audio/amr-wb-plusW/AudioCapabilitIEs(25467): Unsupported mime audio/mpeg-L1W/AudioCapabilitIEs(25467): Unsupported mime audio/mpeg-L2D/ConnectivityManager(25467): CallingUID : 10063, CallingPID : 25467D/ConnectivityManager.CallbackHandler(25467): CM callback handler got msg 524290W/AudioCapabilitIEs(25467): Unsupported mime audio/x-ms-wmaW/AudioCapabilitIEs(25467): Unsupported mime audio/x-imaW/AudioCapabilitIEs(25467): Unsupported mime audio/qcelpW/AudioCapabilitIEs(25467): Unsupported mime audio/evrcW/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/wvc1W/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/x-ms-wmvW/VIDeoCapabilitIEs(25467): Unrecognized profile/level 32768/2 for vIDeo/mp4v-esW/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/wvc1W/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/x-ms-wmvW/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/x-ms-wmv7W/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/x-ms-wmv8W/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/mp43W/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/sorensonW/VIDeoCapabilitIEs(25467): Unsupported mime vIDeo/mp4v-esdp

请帮助我解决此错误.谢谢

解决方法:

我通过处理ssl Error找到了解决类似问题的方法.基本覆盖WebvIEwclIEnt对象中的onReceivedSslError函数并设置handler.proceed(),消除了问题.

      WebVIEwClIEnt webClIEnt = new WebVIEwClIEnt() {            // OverrIDe page so it's load on my vIEw only            @OverrIDe            public boolean shouldOverrIDeUrlLoading(WebVIEw vIEw, String url) {                return false;            }            @OverrIDe            public voID onPageStarted(WebVIEw vIEw, String url, Bitmap facIcon) {                mLayoutProgress.setVisibility(VIEw.VISIBLE);            }            @OverrIDe            public voID onReceivedSslError(WebVIEw vIEw, SslErrorHandler handler, SslError error) {                    handler.proceed();            }            @OverrIDe            public voID onPageFinished(WebVIEw vIEw, String url) {                mLayoutProgress.setVisibility(VIEw.GONE);            }        };
总结

以上是内存溢出为你收集整理的在API 21及更高版本中,Android Webview加载失败全部内容,希望文章能够帮你解决在API 21及更高版本中,Android Webview加载失败所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1091160.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存