如何隐藏的Andr​​oid的WebView通知? [英] How to Hide Android WebView Notifications?

查看:124
本文介绍了如何隐藏的Andr​​oid的WebView通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用8 - 在一个布局10个不同的网页视图和装载在各个不同的WebView内容

I am using 8 - 10 different WebViews in one layout and loading different content in each WebView.

在加载web视图显示不同的类似信息中..处理...等。

While loading Webview shows different messages like "Loading.." "Processing.." etc.

有什么办法来隐藏这些通知?

Is there any way to hide these notifications?

推荐答案

尝试使用的HttpClient 来获取网页的HTML code,然后用 WebView.loadData 整个页面加载到WebView中。

Try to use HttpClient to get the webpage's html code and then use WebView.loadData to load the entire page into WebView.

private class exampleHttpTask extends AsyncTask<Integer, Integer, String> {
    public String convertStreamToString(InputStream is, String charset) throws IOException {
        if (is != null) {
            Writer writer = new StringWriter();
            char[] buffer = new char[1024];
            try {
                Reader reader = new BufferedReader(new InputStreamReader(is, charset));
                int n;
                while ((n = reader.read(buffer)) != -1) {
                    writer.write(buffer, 0, n);
                }
            } finally {
                is.close();
            }
            return writer.toString();
        } else {
            return "";
        }
    }

    protected String doInBackground(Integer... params) {
        String r = "";
        try {
            HttpClient hc = new DefaultHttpClient();
            HttpGet get = new HttpGet("http://google.com"); // replace with the url
            HttpResponse hr = hc.execute(get);

            if(hr.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                InputStream is = hr.getEntity().getContent();
                r = convertStreamToString(is, "UTF-8");
            } else {
                r = "Error";
            }
        } catch(Exception e){
            e.printStackTrace();
        }
        return null;
    }

    protected void onPostExecute(String result) {
        WebView wv = (WebView) findViewById(R.id.web_view); // replace web_view with the webView id
        wv.loadData(result, "text/html", "utf-8");
    }

    protected void onPreExecute() {
    }

}

然后调用新exampleHttpTask()。EXEC()加载网页。

这篇关于如何隐藏的Andr​​oid的WebView通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆