安卓:下载使用下载管理类的应用程序 [英] Android: Download an application using the DownloadManager class

查看:182
本文介绍了安卓:下载使用下载管理类的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图下载使用下载管理器类在Android中的非市场应用。 我在做什么是以下内容:

I am trying to download a non-market application in Android using the DownloadManager class. what I am doing is the following:

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

的通知栏显示我正在被下载的应用程序。但我不能安装它,或者找到它的设备上。我做错了什么?

The notification bar shows me that the app is being downloaded. But I am not able to install it or to find it on the device. What I am doing wrong?

推荐答案

同样的问题。解决了与调用:

Same problem. Solved with a call to:

public DownloadManager.Request setDestinationUri (Uri uri)

您需要有WRITE_EXTERNAL_STORAG​​E权限。

You need to have WRITE_EXTERNAL_STORAGE permission.

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);

这篇关于安卓:下载使用下载管理类的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆