Android webviewダウンロードファイル

1000 ワード

Android webviewは直接ファイルをダウンロードできません
  • ですので、ダウンロードファイルを実装するには、次の
  • の内蔵ブラウザを呼び出します.
    private class MWebViewDownLoadListener implements DownloadListener {
            @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);
                startActivity(intent);
            }
        }
       webview.setDownloadListener(new MWebViewDownLoadListener());
  • これで