Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

I dont know how you are setting up your download manager but this is how ive used it in the pass.

private long enqueue;
private DownloadManager dm;

public void onClick(View view) {
    dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    Request request = new Request(
            Uri.parse("File URL"));
    enqueue = dm.enqueue(request);

}

public void showDownload(View view) {
    Intent i = new Intent();
    i.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);
    startActivity(i);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top