Android StrictMode政策违规中的WebView; ms:android.os.StrictMode $ StrictModeDiskReadViolation:policy = 287 violation = 2

时间:2015-08-29 06:55:51

标签: android webview

公共类MainActivity扩展了Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final EditText editText = (EditText)findViewById(R.id.textView);
    View view = findViewById(R.id.button);
    final WebView webView = (WebView)findViewById(R.id.webView);
    webView.setWebViewClient(new MyBrowser());
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String url = editText.getText().toString();
            webView.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setLoadsImagesAutomatically(true);
            webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
            webView.loadUrl(url);
        }
    });
}

private class MyBrowser extends WebViewClient{
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}

}

错误状态 得到错误为“不允许加载本地资源:file:///android_asset/webkit/android-weberror.png”,来源:data:text / html,chromewebdata(12)“

0 个答案:

没有答案