我正试图使用DownloadManager
类在android中下载一个非市场应用程序。
我正在做的是:
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Request request = new Request(Uri.parse("PATH_TO_MY_APP"));
long enqueue = dm.enqueue(request);
通知栏显示正在下载应用程序。但我无法安装或在设备上找到它。我做错什么了?
最佳答案
同样的问题。通过呼叫解决:
public DownloadManager.Request setDestinationUri (Uri uri)
您需要具有“写入外部存储”权限。
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);
关于android - Android:使用DownloadManager类下载应用程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11121121/