android webview处理下载内容

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;
            }
        });
android webview处理下载内容

 

 

MyWebViewDownLoadListener:

 

android webview处理下载内容
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);
    }

}
android webview处理下载内容

android webview处理下载内容,布布扣,bubuko.com

android webview处理下载内容

上一篇:android保存server端的sessionid


下一篇:袋鼠云助力明星论坛上云,520000+海内外粉丝共享流畅体验!