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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With