herbertD
herbertD

Reputation: 10965

Android 8.0 DownloadManager not working in MOBILE DATA

I Set this in download manager but it does not work even in WIFI:

request.setAllowedNetworkTypes(DownloadManager.Request.NETWO‌​RK_WIFI | DownloadManager.Request.NETWORK_MOBILE)

And This code below can work: BUT ONLY IN WIFI MODE so that It can NOT download using MOBILE data

request.setAllowedNetworkTypes(DownloadManager.Request.NETWO‌​RK_WIFI) 

Is this a bug in Download Manager?

Upvotes: 1

Views: 2231

Answers (4)

Change Android Manifest permission external write permission like below,

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/>

Upvotes: 1

Cameron Wong
Cameron Wong

Reputation: 68

I have similar problem. But removing line of setAllowedNetworkTypes doesn't work.

My problem can be reproduced on 8.1 emulator. But it works well on a real device.

My solution is to setAllowedOverRoaming(false). I don't know why.

Upvotes: 2

herbertD
herbertD

Reputation: 10965

As the developer says:

setAllowedNetworkTypes

added in API level 9
public DownloadManager.Request setAllowedNetworkTypes (int flags)
Restrict the types of networks over which this download may proceed. By default, all network types are allowed. Consider using setAllowedOverMetered(boolean) instead, since it's more flexible.

So just remove this line will work.

Upvotes: 0

gnehz972
gnehz972

Reputation: 11

Check network availability, especially the wifi/mobile signal icon on statusbar. If a little cross is there, the system will treat it as no net and will not proceed downloading(I've encountered this recently).

Upvotes: 1

Related Questions