Android 下载管理器和 SSL (https)
哦,太好了。总有一些其他的东西......呃......
无论如何,所以我日复一日地费力地浏览模糊、不完整和矛盾的 Picasa 信息,以便我的 Android 应用程序可以找到 Picasa 图片并使用下载管理器下载它。所以刚才我做了最后的润色并点击了“运行”按钮。一切都很顺利,直到 DownloadManager 尝试下载文件:
java.lang.IllegalArgumentException: Can only download HTTP URIs: https://example.com/image.jpg
告诉我你在开玩笑。告诉我他们没有制作无法处理 SSL 的下载管理器...
更好的是,告诉我如何在 Android 下载管理器中打开 SSL 访问。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我以前也遇到过同样的问题。是的,我看到 ICS 中已经支持 HTTPS,但 2.3.7 及以下版本中没有,但我们可以提取源代码来创建一个 DownloadManager 来支持它。
基于以下示例代码
http://android-er.blogspot.com/2011 /07/sample-code-using-androidappdownloadman.html
我用提取的 DownloadManager 做了一个演示来支持 HTTPS。
您可以在此处找到示例代码 https://github.com/alvinsj/android-https- downloadmanager-demo,只需将 url 更改为基于 https 的 url 即可运行。
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.
是的,
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 网站上使用它。
Yes it seems that
DownloadManager
only supportsHTTP
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=343I'm disappointed too as I just wanted to use it on a HTTPS site.
我找到了一个非常简单的解决方案:
request = new DownloadManager.Request(sourceUrl.replace("https://", "http://"))
令人惊讶的是,适用于所有 https URL我尝试过。我不确定 https 安全性,但没有例外,并且文件可以正确下载。
I've found a very easy solution for this:
request = new DownloadManager.Request(sourceUrl.replace("https://", "http://"))
Surprisingly worked for all https URLs that I tried. I'm not sure about the https security, but there is no exception and file gets downloaded properly.