2016-04-15 121 views
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視圖中工作。

+0

你有權利寫write_external_storage –

+0

嘗試硬編碼爲測試目的的已知路徑,看看是否寫入適當的位置 –

+0

是我採取了許可,它是下載成功,如果我使用GET請求 –

回答

4

不幸的是DownloadManager不支持POST方法。請找到相應的問題39491780

您將不得不使用其他方法在應用程序中下載文件。