且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

安卓:设置HttpURLConnection的速度极限

更新时间:2023-10-08 23:39:58

我会做的要么是使用下载管理器为previous评论者建议,如果你的API级别9+发展。麻烦的是这是一个下载在通知栏显示,你可能不希望这样。

What I would do is either use the DownloadManager as the previous commenter suggested, if you're developing for API level 9+. The trouble is with this is that downloads are shown in the notification bar and you might not want that.

据我可以看到有没有办法限制使用与Android使用HttpClient的一个特定的下载带宽。但我猜测你是下载使用每个文件中的AsyncTask的文件,AsyncTasks被串行执行,因此这可能解释为什么第二个文件没有开始下载。

As far as I can see there is no way to limit bandwidth on a specific download using the HttpClient used with Android. But I am guessing that you are downloading the file using an AsyncTask per file, and AsyncTasks are executed serially therefore that might explain why the 2nd file doesn't start downloading.

我强烈建议在 RoboSpice 寻找这是完美的这种类型的后台下载的。我是pretty相信你一定能够一次同时下载多个文件。

I strongly suggest looking at RoboSpice which is perfect for this type of background downloading. I'm pretty sure you will be able to download multiple files at once as well.