• android webview处理下载内容


    url = "http://m.mumayi.com/";
            WebView = (WebView) findViewById(R.id.webView1);
            WebView.getSettings().setJavaScriptEnabled(true);
            WebView.requestFocus();
            WebView.getSettings().setDefaultTextEncodingName("utf-8");
            WebView.loadUrl(url);
            // 设置web视图客户端
            WebView.setDownloadListener(new MyWebViewDownLoadListener(
                    DownLoadActivity.this));
            WebView.setWebViewClient(new WebViewClient() {
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    WebView.loadUrl(url);
                    return true;
                }
            });

    MyWebViewDownLoadListener:

    public class MyWebViewDownLoadListener implements DownloadListener {
        private Context context;
    
        public MyWebViewDownLoadListener(Context context) {
            this.context = context;
        }
    
        @Override
        public void onDownloadStart(String url, String userAgent,
                String contentDisposition, String mimetype, long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            context.startActivity(intent);
        }
    
    }
  • 相关阅读:
    Hello World基于.net framework中CLR的执行
    MVN常用命令
    Git常用命令
    Markdown常用语法
    计算机专用英语词汇
    Windows DiskPart
    字符集过滤器
    SSHkey
    书名
    redis
  • 原文地址:https://www.cnblogs.com/androidsuperman/p/3580916.html
Copyright © 2020-2023  润新知