Android reliable download large file






















To download a 2k or 2gb file the actual code is the same using some type of connection handler and some type of input stream and output stream and usually wrapping the input stream with a buffered input stream. For that you can find infinite amount of java examples all around the web. The trick here considering the Android platform is that because it's a lengthy operation, you shouldn't be doing it inside the activity life cycle at all.

The IntentService automatically spans a new thread, through the intent you pass the URL as a String and let the service download using the streams, etc. It shouldn't be difficult to call getSystemService Context. If you're not targeting pre-Gingerbread devices, I would use DownloadManager as suggested as the third option in the answer you linked to. It takes care of downloading the file, displays the progress in the notification bar so that the user can see what's going on even after your app has gone into the background and you don't have to worry so much about what happens when the user goes into another app and android decides to kill your app to free memory.

Also, it works with features like "only download files over wifi" that at least some android builds have. I suggest you to use adm download manager. Downloads never fail even if there is no network and the speed is also best. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. The best way to download a big file in android? Ask Question. Asked 8 years, 7 months ago.

Active 8 years, 2 months ago. Viewed 22k times. Could you guys give a hint, how to do that? Improve this question. Community Bot 1 1 1 silver badge. Victor Laerte Victor Laerte 6, 13 13 gold badges 50 50 silver badges 96 96 bronze badges. Add a comment. Active Oldest Votes. Said that you have two options: as you suggested you can create a Service, I would suggest you to use the IntentService as it seems to be a perfect fit for this case.

Asked 11 years ago. Active 3 years, 10 months ago. Viewed 15k times. I start the device with "Wipe data user" The length of the size from conexion. I've double checked that I can download the file through a web browser. After a while, the emulator reboots itself. Workarounds: This issue in stackoverflow is working in the device, not in my case. Thank you very much. Update with more log description: Hi Chris, I've tried to discover what was going on at first with this log in the Eclipse environment.

Could anyone try my code and to download a zip file with size round 8MB? Does it works for you? Community Bot 1 1 1 silver badge. Thanks for this code, worked perfectly the first time, on my Samsung S3.

Add a comment. Active Oldest Votes. Hi, I have the same problem. Did you manage to make it work on the emulator? In the second tab on the left of the AVD manager, select "Installed packages" and "Update all", it will tell you if there is a new version. Chris Stratton Chris Stratton Hi Chris, more details on my original question about this log. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Email Required, but never shown. The Overflow Blog.



0コメント

  • 1000 / 1000