Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView download not working

I have created one web view having page containing html form and on submitting form (with post method) it should download the file.

I have implemented webview download listener so i can handle downloads.

@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);
}

Now problem is, If i use post method in HTML FORM in page, download not working(it is working if i use GET method)

in chrome mobile app it's works with post method, but it is not working in android web view.

like image 527
Parth Gajjar Avatar asked Apr 15 '16 13:04

Parth Gajjar


1 Answers

Unfortunately DownloadManager doesn't support POST method. Please find the corresponding issues 3949 and 1780.

You will have to use alternative means to download the file in your application.

like image 146
Anirudha Agashe Avatar answered Oct 23 '22 04:10

Anirudha Agashe