Reputation: 3972
My Android app needs to do a large (~150MB) download in the background. I am using an intent service and doing this in the background.
The problem is that this big download cloggs all other downloads.
(I'm using Volley+Glide for image downloads in the app and OkHTTP for the large file download. I would use Volley for everything, but since it's not recommended for large files, I'm using okHttp.)
Volley has a way of setting download priorities, but AFAIK, that's only used to determine WHEN a download starts, not for the % of bandwidth a d/l uses.
I was not able to find a way to set okHTTP to download at a very low priority.
Ideally, what I would like to do is just set the large okHttp download to a very low priority, and it would let everything else download.
Upvotes: 0
Views: 466
Reputation: 40593
Create a class called ThrottledSource
that extends Okio’s ForwardingSource. This class needs to limit the kilobytes per second. You can see examples of throttling a stream in MockWebServer.java.
When you're done you'll have a stream that downloads slower than it needs to. That'll free up bandwidth for other transfers.
Upvotes: 1
Reputation: 506
Upvotes: 0