android https downloads,android - download HTTP/HTTPS URIs with DownloadManager - Stack Overflow

I googled and find something about this. But that doesn't help.

Android Version: 4.0+

here's my code:

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

Scheme is https, but I still get an error:

02-10 11:18:23.710 E/AndroidRuntime( 7550): java.lang.RuntimeException: Unable to start service com.souyidai.investment.android.service.DownloadService@4344e5e0 with Intent { act=download_with_download_manager cmp=com.souyidai.investment.android/.service.DownloadService (has extras) }: java.lang.IllegalArgumentException: Can only download HTTP/HTTPS URIs: https://static.test.com/downloads/xxx.apk

02-10 11:18:23.710 E/AndroidRuntime( 7550): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2711)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at android.app.ActivityThread.access$2100(ActivityThread.java:141)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1299)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at android.os.Handler.dispatchMessage(Handler.java:102)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at android.os.Looper.loop(Looper.java:136)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at android.app.ActivityThread.main(ActivityThread.java:5047)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at java.lang.reflect.Method.invokeNative(Native Method)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at java.lang.reflect.Method.invoke(Method.java:515)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at dalvik.system.NativeStart.main(Native Method)

02-10 11:18:23.710 E/AndroidRuntime( 7550): Caused by: java.lang.IllegalArgumentException: Can only download HTTP/HTTPS URIs: https://static.test.com/downloads/xxx.apk

02-10 11:18:23.710 E/AndroidRuntime( 7550): at android.app.DownloadManager$Request.(DownloadManager.java:642)

02-10 11:18:23.710 E/AndroidRuntime( 7550): at com.souyidai.investment.android.service.DownloadService.onStartCommand(DownloadService.java:114)

Here's the DownloadManager.Request code:

public Request(Uri uri) {

if (uri == null) {

throw new NullPointerException();

}

String scheme = uri.getScheme();

if (scheme == null || (!scheme.equals("http") && !scheme.equals("https"))) {

throw new IllegalArgumentException("Can only download HTTP/HTTPS URIs: " + uri);

}

mUri = uri;

}

Any ideas?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值