Webview未在Nexus设备上加载网址

时间:2016-07-08 10:15:19

标签: android webview

早些时候webbview工作正常,但今天出现了奇怪的问题,当我加载网址时显示这个..

enter image description here

此代码是....

public class ShowSubjectListItemsInWebView extends ActionBarActivity {
    private WebView webView;
    private Toolbar mToolbar;
    private SessionManager sessionManager;
    private Security security;
    private ProgressDialog dialog;
    private String url;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_subject_list_items_in_web_view);
        this.initViews();
        this.setToolBar();
        try{

            sessionManager = new SessionManager(getApplicationContext());
            security = new Security(getApplicationContext());
            boolean isInternetPresent = security.isConnectingToInternet();
            if (isInternetPresent) {
               //I hide url due to some privacy contents                    
                loadWebView(url);
            } else {
                showCustomToast("Internet not available \n Please check your internet connection");
            }
        }catch(Exception ex){
            showCustomToast("Something went wrong");
        }

    }

    //initializes all views
    private void initViews() {
        webView = (WebView) findViewById(R.id.filesWebView);
    }

    //show Url in WebView
    public class myWebClient extends WebViewClient {
        @JavascriptInterface
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // TODO Auto-generated method stub
            super.onPageStarted(view, url, favicon);
            dialog = new ProgressDialog(ShowSubjectListItemsInWebView.this);
            dialog.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
            dialog.setCancelable(false);
            dialog.setMessage(Constant.KEY_PLEASE_WAIT);
            dialog.show();
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // TODO Auto-generated method stub
            super.onPageFinished(view, url);
            if (dialog.isShowing()) {
                dialog.dismiss();
            }
        }
    }

    public void loadWebView(String decryptedUrl) {
        webView.setWebViewClient(new myWebClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setDomStorageEnabled(true);
        webView.setVisibility(View.VISIBLE);
                webView.loadUrl(decryptedUrl);
    }

    }

我在lenovo,moto和MI设备上测试了这个代码...工作正常但是当我选择nexus设备加载url时它会给出上述错误。

0 个答案:

没有答案
相关问题