gpt4 book ai didi

Android WebView 下载不工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:42:34 31 4
gpt4 key购买 nike

我创建了一个包含 html 表单的网页 View ,在提交表单时(使用 post 方法)它应该下载文件。

我已经实现了 webview 下载监听器,所以我可以处理下载。

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

现在的问题是,如果我在页面的 HTML FORM 中使用 post 方法,则下载不工作(如果我使用 GET 方法则可以工作)

在 chrome 移动应用程序中,它适用于 post 方法,但它不适用于 android web View 。

最佳答案

很遗憾,DownloadManager 不支持POST 方法。请找对应的issues 39491780 .

您必须使用其他方式在您的应用程序中下载该文件。

关于Android WebView 下载不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36648268/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com