I want to download a binary file from a url. Is it possible to use the Android download manager class that I found here DownloadManager class?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Yes, though that is only available since Android API Level 9 (version 2.3). Here is a sample project demonstrating the use of
DownloadManager
.Use DownloadManager class (GingerBread and newer only)
GingerBread brought a new feature, DownloadManager, which allows you to download files easily and delegate the hard work of handling threads, streams, etc. to the system.
First, let's see a utility method:
Method's name explains it all. Once you are sure DownloadManager is available, you can do something like this:
Download progress will be showing in the notification bar.
Make sure the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions is in your Manifest.xml file:
And then include this code in your download function