Android DownloadManager“下载需要网络”错误
我正在使用 DownloadManager 对正在进行的一些下载进行排队,但当我专门尝试使用移动/4G 连接时遇到此问题。我使用的是 Android 2.3.4 手机。我的代码使用 2.3.3 API。
我正在执行以下命令(我想强制连接使用 4G/3G),
request.setAllowedNetworkTypes(Request.NETWORK_MOBILE);
但是每当它尝试下载时,它都会将下载放在 DownloadManager 列表中,但它永远保持在“正在进行”状态,并且出现错误顶部列出了文件名和错误“下载需要网络”。
当我进一步调查并连接我的设备以查看 logcat 中的日志时,我在尝试下载时看到以下错误:
正在中止下载请求 92:请求下载不使用当前网络类型
我有以下权限:
android.permission.WRITE_OWNER_DATA
android.permission.READ_OWNER_DATA
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_WIFI_STATE
android.permission.CHANGE_WIFI_MULTICAST_STATE
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_STATE
任何想法它可能是什么?我还缺少许可吗?我是否需要控制其他设置来指定仅使用网络连接?
编辑: 我已经在全新的 Galaxy 平板电脑上尝试过此操作,这是我在使用该设备时注意到的行为:当 wifi 打开并连接时,在指定使用 NETWORK_MOBILE 时无法下载。如果wifi关闭或未连接,使用4G连接没有问题。我认为这是设备正在执行的安全功能,可以覆盖吗?
I'm using the DownloadManager to queue up some downloads I'm making but running into this issue when I specifically try to use the Mobile/4G connection. I'm using an Android 2.3.4 phone. My code is using the 2.3.3 API.
I'm doing the following command (I want to force the connection to use 4G/3G)
request.setAllowedNetworkTypes(Request.NETWORK_MOBILE);
Whenever it attempts to download however, it places the download in the DownloadManager listing but it forever remains in the status "In progress" and an error at the top lists the file name and the error "Download requires network."
When I investigate further and connected my device to see the logs in logcat, I see the following error when it attempts to download:
Aborting request for download 92: download was requested to not use the current network type
I have the following permissions:
android.permission.WRITE_OWNER_DATA
android.permission.READ_OWNER_DATA
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_WIFI_STATE
android.permission.CHANGE_WIFI_MULTICAST_STATE
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_STATE
Any ideas of what it could be? Am I still missing a permission? Is there another setting that I need to control to specify the use of the Network connection only?
EDIT:
I have tried this on a brand new Galaxy tablet and this is the behavior I notice using this device: When the wifi is on and connected, it fails to download when specifying to use the NETWORK_MOBILE. If the wifi is turned off or not connected, it has no problem using the 4G connection. I'm thinking this is a security feature being done by the device, can this be overidden?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道你是如何设置你的下载管理器的,但这就是我在通行证中使用它的方式。
I dont know how you are setting up your download manager but this is how ive used it in the pass.
当您没有数据连接时(无论您是否连接到 wifi)都会出现此错误。您可以单独指定 NETWORK_MOBILE,但如果它在您的数据连接当前无法工作时尝试进行下载,则会向您抛出错误,提示“下载需要网络”。
我对再次获得数据连接的建议是四处走动,直到再次获得连接。我可以判断我的 Droid Bionic 手机何时有数据连接,因为顶部栏图标显示 4G LTE,并且 4 栏 变为蓝色而不是白色。
This error occurs when you have no data connection (doesn't matter whether or not you are connected to wifi). You are allowed to specify NETWORK_MOBILE by itself, but it will throw you an error saying "Download Requires Network" if it tries to do the download when your data connection isn't currently working.
My advice to get a data connection again is to walk around until you get a connection again. I can tell when I have a data connection on my Droid Bionic phone because the top bar icons that say 4G LTE and the 4 bars turn blue instead of white.