我有一个使用WebView并加载页面的Android应用程序。此应用程序适用于运行API 16或更高版本的Android设备。
Android WebView代码:
String URL = "https://sandbox.napas.com.vn/gateway/message";
@Override
protected 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/evrc
W/AudioCapabilities(25467): Unsupported mime audio/qcelp
W/VideoCapabilities(25467): Unrecognized profile 2130706433 for video/avc
W/AudioCapabilities(25467): Unsupported mime audio/amr-wb-plus
W/AudioCapabilities(25467): Unsupported mime audio/mpeg-L1
W/AudioCapabilities(25467): Unsupported mime audio/mpeg-L2
D/ConnectivityManager(25467): CallingUid : 10063, CallingPid : 25467
D/ConnectivityManager.CallbackHandler(25467): CM callback handler got msg 524290
W/AudioCapabilities(25467): Unsupported mime audio/x-ms-wma
W/AudioCapabilities(25467): Unsupported mime audio/x-ima
W/AudioCapabilities(25467): Unsupported mime audio/qcelp
W/AudioCapabilities(25467): Unsupported mime audio/evrc
W/VideoCapabilities(25467): Unsupported mime video/wvc1
W/VideoCapabilities(25467): Unsupported mime video/x-ms-wmv
W/VideoCapabilities(25467): Unrecognized profile/level 32768/2 for video/mp4v-es
W/VideoCapabilities(25467): Unsupported mime video/wvc1
W/VideoCapabilities(25467): Unsupported mime video/x-ms-wmv
W/VideoCapabilities(25467): Unsupported mime video/x-ms-wmv7
W/VideoCapabilities(25467): Unsupported mime video/x-ms-wmv8
W/VideoCapabilities(25467): Unsupported mime video/mp43
W/VideoCapabilities(25467): Unsupported mime video/sorenson
W/VideoCapabilities(25467): Unsupported mime video/mp4v-esdp
请帮我修复此错误。感谢
答案 0 :(得分:2)
我通过处理ssl Error找到了类似问题的解决方案。基本覆盖onReceivedSslError
对象中的函数Webviewclient
并设置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);
}
};
答案 1 :(得分:2)
我遇到了同样的问题&我关注了@DRY Believer的答案,但当我将应用程序上传到google Play时,他们拒绝了该应用程序并说你的应用程序正在使用WebViewClient.onReceivedSslError的不安全实现
相反,我找到了一种在服务器上正确安装我的SSL证书的方法,并修复了问题