奥利奥的Webview无法正常工作

时间:2017-11-29 07:52:17

标签: android webview

我在Oreo 8中打开webview时遇到此错误。该设备是Google Pixel。请帮助我。如果您需要任何其他信息,请与我们联系。

  

处理:com.android.chrome:sandboxed_process0,PID:16787                                                      android.content.res.Resources $ NotFoundException:数组资源ID#0x7f030010                                                          在android.content.res.Resources.obtainTypedArray(Resources.java:617)                                                          在android.content.res.Resources.preloadFonts(Resources.java:379)                                                          在android.app.ActivityThread.handleBindApplication(ActivityThread.java:5815)                                                          在android.app.ActivityThread.-wrap1(未知来源:0)                                                          在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1661)                                                          在android.os.Handler.dispatchMessage(Handler.java:105)                                                          在android.os.Looper.loop(Looper.java:164)                                                          在android.app.ActivityThread.main(ActivityThread.java:6541)                                                          at java.lang.reflect.Method.invoke(Native Method)                                                          在com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)                                                          在com.android.internal.os.WebViewZygoteInit.main(WebViewZygoteInit.java:121)

    WebSettings settings = binding.landingWb.getSettings();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        settings.setSafeBrowsingEnabled(true);
    }
    //binding.loader.setVisibility(View.GONE);
    settings.setJavaScriptEnabled(true);
    binding.landingWb.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    binding.landingWb.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url != null) {
                if (url.startsWith("whatsapp://")) {
                    view.getContext().startActivity(
                            new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                    return true;
                } else {
                    view.loadUrl(url);
                    return true;
                }

            } else {
                binding.loader.setVisibility(View.GONE);
                return false;
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            binding.loader.setVisibility(View.GONE);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Log.d(TAG, "onReceivedError() called with: view = [" + view + "], errorCode = [" + errorCode + "], description = [" + description + "], failingUrl = [" + failingUrl + "]");
            binding.loader.setVisibility(View.GONE);
        }
    });
    binding.landingWb.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            Log.e("CompetitionActivity","Progress:  " + newProgress);
        }
    });
    binding.landingWb.loadUrl(url);

1 个答案:

答案 0 :(得分:9)

删除

删除字体的预加载
<meta-data 
    android:name="preloaded_fonts" 
    android:resource="@array/preloaded_fonts" />