Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android DownloadManager and SSL (https)

Oh, great. There's always something else that some... Grrr...

Anyway, so I worked days and days wading through vague, incomplete, and contradictory Picasa information so that my Android app could find a Picasa picture and download it using the download manager. So just now I made the finishing touches and hit the "run" button. Everything went fine until DownloadManager tried to download the file:

java.lang.IllegalArgumentException: Can only download HTTP URIs: https://example.com/image.jpg

Tell me you're joking. Tell me they didn't make a download manager that can't handle SSL...

Better yet, tell me how to turn on SSL access in the Android download manager.

like image 768
Garret Wilson Avatar asked Nov 12 '11 17:11

Garret Wilson


2 Answers

I had the same problem previously. Yup I see HTTPS support is already in ICS, but not in 2.3.7 and below, but we can extract the source code to create a DownloadManager to support that.

Based on the sample code from http://android-er.blogspot.com/2011/07/sample-code-using-androidappdownloadman.html i made a demo with extracted DownloadManager to support HTTPS.

You can find the sample code here https://github.com/alvinsj/android-https-downloadmanager-demo, run by just changing the url to your https based url.

like image 175
alvinsj Avatar answered Oct 13 '22 16:10

alvinsj


Yes it seems that DownloadManager only supports HTTP protocol: http://www.google.com/codesearch#cZwlSNS7aEw/frameworks/base/core/java/android/app/DownloadManager.java&exact_package=android&q=Can%20only%20download%20HTTP%20URIs&type=cs&l=343

I'm disappointed too as I just wanted to use it on a HTTPS site.

like image 23
Peter Knego Avatar answered Oct 13 '22 14:10

Peter Knego