【发布时间】:2015-11-12 15:37:35
【问题描述】:
代码有什么问题,不知道怎么回事? 代码没有错误,但是从android 6开始APP启动错误。
请帮帮我。
long enqueue;
DownloadManager dm;
dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse("http://grupovrt.ddns.net:81/v4.2.apk"));
String updatePath = Environment.getExternalStorageDirectory() + File.separator + "Updates" + File.separator + "v4.2.apk";
request.setDestinationUri(Uri.fromFile(new File(updatePath)));
request.setDestinationInExternalPublicDir("/updates", "v4.2.apk");
enqueue = dm.enqueue(request);
Toast.makeText(getBaseContext(), "Descarc noi actualizari!", Toast.LENGTH_SHORT).show();
如果我删除这一行去
request.setDestinationInExternalPublicDir("/updates", "v4.2.apk");
【问题讨论】:
-
我发现了错误。在 android 6 中无法自动访问存储空间并给出错误。我如何请求在 android m 中允许它们?
-
@请检查下面我的答案中的链接
标签: android android-studio android-6.0-marshmallow