DownloadManager请求在Android Pie上延迟 [英] DownloadManager requests delayed on Android Pie

查看:106
本文介绍了DownloadManager请求在Android Pie上延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 DownloadManager API来处理一个应用程序中的下载大约3年.最近,我有一些使用Android Pie的用户抱怨有时下载会在真正开始前停留几分钟,从而损害了UX:其中一些不得不重新安装应用程序才能使其正常工作,而另一些用户则随着时间的流逝解决了这个问题.请注意,我没有为DownloadManager.Request实例设置任何特殊设置(例如 allowedNetworkTypes setRequiresCharging ,...).

I have been using the DownloadManager APIs to handle downloads in one app for about 3 years. Recently I had some users on Android Pie complaining that sometimes downloads get stuck for several minutes before actually starting, thus compromising the UX: some of them had to reinstall the app to make them work correctly, some others had the issue fixed itself over time. Please note that I haven't set any special settings to the DownloadManager.Request instances (e.g. allowedNetworkTypes, setRequiresCharging, ...).

我对问题的理解是,请求被卡在待处理已暂停状态很长一段时间,然后再开始使用.没有注意到SDK 28中引入的任何重大更改,尽管这并不重要,因为我的目标是API级别27.

My understanding of the problem is that requests get stuck in the pending or paused status for a long time before getting started. Didn't notice any significant changes introduced in the SDK 28, although it's not important since I'm targeting API level 27.

有人经历过类似的事情并提出了一些解决方法吗?谢谢

Has anyone experienced something similar and came up with some workarounds? Thank you

推荐答案

如上所述,清除下载管理器缓存和数据可解决Android 9 Pie上的此问题.要清除这些设置,您需要转到 Apps&通知,单击<代码>查看所有应用的选项,点击右上角的选项菜单,选择<代码>显示系统,选择<代码>下载管理器从列表中,点击 Storage ,然后清除缓存和存储.

As mentioned in the comments above, clearing the Download manager cache and data resolves this problem on Android 9 Pie. To clear these settings, you need to go to Apps & notifications, click the option to See all apps, tap the options menu in the upper-right corner, select Show system, select Download Manager from the list, tap on Storage, then clear the cache and storage.

解决此问题时,我发现尝试使用DownloadManager将文件下载到公共目录时,如果使用了公共下载位置,则会在日志中写入以下警告:

When troubleshooting this problem I discovered that when trying to use DownloadManager to download a file to a public directory, the following warning was written to the log if a public download location was used:

DownloadManager: Path appears to be invalid: /storage/emulated/0/Download/File Name

无论应用程序是否具有存储权限,都会出现此错误.但是,它似乎是由 isFilenameValidInExternalPackage()(

This error appears irrespective of whether the app has the storage permission. However, it appears to be a false warning that is logged by isFilenameValidInExternalPackage() (source code) when checking if the file is outside an app directory and is run even if the app has the storage permission. As such, this false warning continues to appear even after clearing DownloadManager's cache and storage, although the download works anyway.

此问题似乎定期发生.通常,强制停止Download Manager可以临时解决该问题.希望Google发布永久修复程序.

this problem appears to recur periodically. Typically, force stopping Download Manager resolves it temporarily. Hopefully Google releases a permanent fix.

这篇关于DownloadManager请求在Android Pie上延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆