2

我正在尝试使用DownloadManager该类在 Android 中下载非市场应用程序。我正在做的是以下内容:

DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Request request = new Request(Uri.parse("PATH_TO_MY_APP"));
long enqueue = dm.enqueue(request);

通知栏显示正在下载该应用程序。但我无法安装它或在设备上找到它。我做错了什么?

4

1 回答 1

15

同样的问题。通过调用解决:

public DownloadManager.Request setDestinationUri (Uri uri)

您需要拥有 WRITE_EXTERNAL_STORAGE 权限。

Uri src_uri = Uri.parse("http://your.url.here/File.apk");
Uri dst_uri = Uri.parse("file:///mnt/sdcard/download/File.apk");

DownloadManager.Request req = new DownloadManager.Request(src_uri);
req.setDestinationUri(dst_uri);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(req);
于 2012-06-21T20:09:03.950 回答