我尝试阅读其他主题,但没有任何方法可以帮助我,所以我正在创建这个新问题。
我有一个包含webView的活动,但内容似乎没有加载(在模拟器上,因为这是我现在唯一的“设备”)。
这是我的代码: 公共类WebViewActivity扩展了AppCompatActivity {
WebView webView;
private ProgressDialog progressBar;
String link;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
// Hide action bar
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
webView = (WebView) findViewById(R.id.webView);
Intent intent = getIntent();
link = (String) intent.getSerializableExtra(Constants.intentForWebView);
progressBar = ProgressDialog.show(this,"loading","please wait");
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setDomStorageEnabled(true);
webView.setWebViewClient(new MyWebViewClient());
webView.loadUrl(link);
}
private class MyWebViewClient extends WebViewClient {
@Override
public void onPageFinished(WebView view, String url) {
if (progressBar != null && progressBar.isShowing()) {
progressBar.dismiss();
}
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return super.shouldOverrideUrlLoading(view, request);
}
}
}
添加了LogCat
1-07 23:46:39.422 11215-11215/com.android.xxx D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: false
01-07 23:46:39.506 11215-11215/.xxx I/cr_Ime: ImeThread is not enabled.
01-07 23:46:39.521 11215-11568/.xxx E/chromium: [ERROR:gles2_cmd_decoder.cc(2167)] [GroupMarkerNotSet(crbug.com/242999)!:54278386]GL ERROR :GL_INVALID_OPERATION : BackFramebuffer::Create: <- error from previous GL command
01-07 23:46:39.671 11215-11220/.xxx I/art: JIT allocated 61KB for compiled code of void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
01-07 23:46:39.671 11215-11220/.xxx I/art: Compiler allocated 4MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
01-07 23:46:39.743 11215-11333/com.android.xxx.xxx
E/EGL_emulation: tid 11333: eglSurfaceAttrib(1146): error 0x3009 (EGL_BAD_MATCH)
01-07 23:46:39.743 11215-11333/.xxx W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x8173c680, error=EGL_BAD_MATCH
01-07 23:46:39.860 11215-11333/.xxx E/EGL_emulation: tid 11333: eglSurfaceAttrib(1146): error 0x3009 (EGL_BAD_MATCH)
01-07 23:46:39.860 11215-11333/.xxx W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x8173cd60, error=EGL_BAD_MATCH
01-07 23:46:39.962 11215-11215/.xxx W/art: Attempt to remove non-JNI local reference, dumping thread
01-07 23:46:39.972 11215-11226/.xxx I/art: Background sticky concurrent mark sweep GC freed 4437(348KB) AllocSpace objects, 5(100KB) LOS objects, 0% free, 65MB/65MB, paused 6.043ms total 30.859ms
01-07 23:46:40.294 11215-11215/.xxx W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 11215
01-07 23:46:40.536 11215-11215/.xxx W/art: Attempt to remove non-JNI local reference, dumping thread
01-07 23:46:40.624 11215-11222/.xxx W/art: Suspending all threads took: 14.950ms
01-07 23:46:40.642 11215-11226/.xxx I/art: Background partial concurrent mark sweep GC freed 325(10KB) AllocSpace objects, 1(7MB) LOS objects, 7% free, 50MB/54MB, paused 7.109ms total 32.209ms
01-07 23:46:41.379 11215-11215/.xxx W/art: Attempt to remove non-JNI local reference, dumping thread
01-07 23:46:41.454 11215-11215/.xxx W/art: Attempt to remove non-JNI local reference, dumping thread
01-07 23:46:41.519 11215-11215/.xxx W/art: Attempt to remove non-JNI local reference, dumping thread
01-07 23:46:41.597 11215-11215/.xxx W/art: Attempt to remove non-JNI local reference, dumping thread
01-07 23:46:41.674 11215-11215/.xxx W/art: Attempt to remove non-JNI local reference, dumping thread
01-07 23:46:41.735 11215-11215/.xxx W/art: Attempt to remove non-JNI local reference, dumping thread
答案 0 :(得分:1)
解决!
问题似乎是在没有有效证书的情况下加载网站。添加带有在模拟器中加载的证书的URL的URL