3
我創建了一個網頁視圖,其中包含html表單的頁面和提交表單(使用post方法)應該下載該文件。Android WebView下載不起作用
我已經實施webview download listener
所以我可以處理下載。
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition,
String mimetype, long contentLength) {
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "DownloadFile.pdf");
DownloadManager dm = (DownloadManager) getContext().getSystemService(Activity.DOWNLOAD_SERVICE);
dm.enqueue(request);
}
現在的問題是, 如果我在頁面中使用POST方法在HTML表單,下載不工作(這是工作,如果我使用GET法)
在Chrome移動應用程序它的作品與post方法,但它不能在android web視圖中工作。
你有權利寫write_external_storage –
嘗試硬編碼爲測試目的的已知路徑,看看是否寫入適當的位置 –
是我採取了許可,它是下載成功,如果我使用GET請求 –