18

哦,太好了。总有一些其他的东西...... Grrr......

无论如何,所以我日复一日地在模糊、不完整和矛盾的 Picasa 信息中工作,以便我的 Android 应用程序可以找到一张 Picasa 图片并使用下载管理器下载它。所以刚才我做了最后的润色并按下“运行”按钮。一切都很好,直到 DownloadManager 尝试下载文件:

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

告诉我你在开玩笑。告诉我他们没有制作无法处理 SSL 的下载管理器...

更好的是,告诉我如何在 Android 下载管理器中打开 SSL 访问。

4

3 回答 3

7

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.

于 2012-05-10T12:21:37.627 回答
1

是的,它似乎DownloadManager只支持HTTP协议: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

我也很失望,因为我只想在 HTTPS 网站上使用它。

于 2011-11-12T17:38:54.753 回答
-5

我为此找到了一个非常简单的解决方案:

request = new DownloadManager.Request(sourceUrl.replace("https://", "http://"))

令人惊讶的是,我尝试过的所有 https URL 都有效。我不确定 https 的安全性,但也不例外,文件已正确下载。

于 2012-06-28T09:05:30.003 回答