无法正确加载webview

时间:2016-08-25 13:08:34

标签: android webview

我的网页在webview中看起来像这样

enter image description here

看起来应该是这样,因为它正在寻找chrome

enter image description here

我的logcat显示此消息

08-25 18:18:57.144: I/Timeline(29337): Timeline: Activity_launch_request id:com.loconav time:199729854
08-25 18:18:57.230: I/WebViewFactory(29337): Loading com.android.webview version 39 (970e0cea82-arm64) (code 300002)
08-25 18:18:57.242: I/LibraryLoader(29337): Time to load native libraries: 2 ms (timestamps 9950-9952)
08-25 18:18:57.242: I/LibraryLoader(29337): Expected native library version number "",actual native library version number ""
08-25 18:18:57.250: V/WebViewChromiumFactoryProvider(29337): Binding Chromium to main looper Looper (main, tid 1) {255dd03a}
08-25 18:18:57.251: I/LibraryLoader(29337): Expected native library version number "",actual native library version number ""
08-25 18:18:57.251: I/chromium(29337): [INFO:library_loader_hooks.cc(104)] Chromium logging enabled: level = 0, default verbosity = 0
08-25 18:18:57.258: I/BrowserStartupController(29337): Initializing chromium process, singleProcess=true
08-25 18:18:57.259: W/art(29337): Attempt to remove local handle scope entry from IRT, ignoring
08-25 18:18:57.267: W/AudioManagerAndroid(29337): Requires BLUETOOTH permission
08-25 18:18:57.269: W/chromium(29337): [WARNING:resource_bundle.cc(304)] locale_file_path.empty()
08-25 18:18:57.271: E/AwAssets(29337): Error while loading asset .pak: java.io.FileNotFoundException: .pak
08-25 18:18:57.271: W/chromium(29337): [WARNING:aw_browser_main_parts.cc(71)] Failed to load .pak.pak from the apk too. Bringing up WebView without any locale
08-25 18:18:57.271: E/AwAssets(29337): Error while loading asset webviewchromium.pak: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
08-25 18:18:57.271: W/chromium(29337): [WARNING:aw_browser_main_parts.cc(87)] Cannot load webviewchromium.pak assets from the apk. Falling back loading it from /data/data/com.loconav/app_webview/paks
08-25 18:18:57.271: E/chromium(29337): [ERROR:resource_bundle.cc(677)] Failed to load /data/data/com.loconav/app_webview/paks/webviewchromium.pak
08-25 18:18:57.271: E/chromium(29337): Some features may not be available.
08-25 18:18:57.317: W/chromium(29337): [WARNING:data_reduction_proxy_settings.cc(331)] SPDY proxy OFF at startup
08-25 18:18:57.325: W/art(29337): Attempt to remove local handle scope entry from IRT, ignoring
08-25 18:18:57.329: W/AwContents(29337): onDetachedFromWindow called when already detached. Ignoring
08-25 18:18:57.339: W/chromium(29337): [WARNING:resource_bundle.cc(403)] Unable to load image with id 5715
08-25 18:18:57.495: I/Timeline(29337): Timeline: Activity_idle id: android.os.BinderProxy@12f5a663 time:199730205
08-25 18:19:05.537: W/chromium(29337): [WARNING:resource_bundle.cc(403)] Unable to load image with id 5715
08-25 18:22:22.634: W/IInputConnectionWrapper(29337): showStatusIcon on inactive InputConnection
08-25 18:22:23.141: I/OpenGLRenderer(29337): Initialized EGL, version 1.4
08-25 18:22:23.987: I/OpenGLRenderer(29337): Initialized EGL, version 1.4
08-25 18:22:25.868: I/OpenGLRenderer(29337): Initialized EGL, version 1.4
08-25 18:22:25.933: I/Timeline(29337): Timeline: Activity_idle id: android.os.BinderProxy@12f5a663 time:199938643

我正在使用此代码

webview = (WebView) findViewById(R.id.webview);
        webview.setWebViewClient(new WebViewClient(){

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url)
            {
                return super.shouldOverrideUrlLoading(view, url);
            }

            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                dialog.show();
                //pd = new ProgressDialog(WebActivity.this,R.style.MyTheme);
                //pd.setCancelable(false);
                //pd.setProgressStyle(android.R.style.Widget_ProgressBar_Large);
                //pd.show();
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                if(url.equals("http://loconav.com/m/dashboard")){
                    editor.putString("login", "true");
                    editor.commit();
                    trytologin = false;
                }else if(url.equals("http://loconav.com/")){
                    editor.clear();
                    editor.commit();
                    Intent intent = new Intent(WebActivity.this,MainActivity.class);
                    if(trytologin == true){
                        intent.putExtra("login", "failed");
                    }
                    startActivity(intent);
                    finish();
                }
                dialog.dismiss();
                //pd.dismiss();
                //Toast.makeText(WebActivity.this, url, Toast.LENGTH_LONG).show();
            }
        });
        webview.setWebChromeClient(new WebChromeClient(){
             @Override
                public boolean onConsoleMessage(ConsoleMessage cm)
                {
                    Log.e("CONTENT", String.format("%s @ %d: %s", 
                                cm.message(), cm.lineNumber(), cm.sourceId()));
                    return true;
                }
        });
        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setAllowContentAccess(true);
        webview.getSettings().setAppCacheEnabled(true);
        webview.getSettings().setDatabaseEnabled(true);
        webview.getSettings().setDomStorageEnabled(true);
        webview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
        webview.getSettings().setSupportZoom(true);
        webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        webview.getSettings().setAllowFileAccessFromFileURLs(true);
        webview.getSettings().setAllowUniversalAccessFromFileURLs(true);
        webview.getSettings().setLoadsImagesAutomatically(true);
        webview.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        //webview.loadUrl("http://www.google.com");
        //webview.loadUrl("http://www.google.com");
        if(sharedpreferences.getString("login", "").equals("")){
            String url = "http://loconav.com/";
            String postData = "user[email]="+username+"&user[password]="+password;
            webview.postUrl(url, EncodingUtils.getBytes(postData, "BASE64"));
        }else{
            if(isNetworkAvailable()){
                webview.loadUrl("http://loconav.com/m/dashboard");
            }else{
                alertDialog();
            }
        }

请帮助我为什么我没有得到正确的webview,因为它应该是任何css文件的错误,我该如何解决它

0 个答案:

没有答案