简体   繁体   中英

Android DownloadManager class not working mobile 4G data?

I have developed an android application using Android DownloadManager Class. When I try to download file over WiFi working without issue but when I use mobile data downloading not working, showing waiting for network.

This is my code:

DownloadManager.Request request = new DownloadManager.Request(Uri.parse((urlString)));

manifest.xml permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

and this is my reference page: Android DownloadManager example

From what you've provided I can only recommend you to remove the unnecessary code sa request.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE); because it by default allows all types of network. Also make sure you haven't set setAllowedOverMetered() and setAllowedOverRoaming() to false.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM