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());