如何解决启用wifi热点后,DownloadManager请求未启动
我有一台正在运行Web服务器的设备。 设备使用其wifi热点连接到我的Android 10智能手机。 在我的应用中,我正在Web视图中显示设备的网页。 我正在尝试将文件从Webview下载到我的智能手机:
public boolean shouldOverrideUrlLoading(WebView view,String url) {
if (url.endsWith(".ext")) {
try {
Uri source = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(source);
request.setDescription("Demo .ext file");
request.setTitle("Demo.ext");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,"Demo.ext");
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
下载URL例如为“ http://192.168.43.1/data/Demo.ext”。
不幸的是,当我的智能手机启用了热点时,下载无法开始。 一旦禁用热点并连接到wifi网络(或启用数据),下载就会开始。 但是,下载不会成功,因为必须从禁用热点的设备上下载文件,而该设备显然不再连接了。
当使用Google Chrome(而不是我的应用)访问我的设备时,下载将起作用。
是否可以使用我的应用程序中的webview开始下载?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。