【发布时间】:2014-12-29 20:38:27
【问题描述】:
我正在创建一个应用程序来安装从服务器下载的应用程序。我想安装这些应用程序下载文件后,我用来安装的方法的代码在这里:
public void Install(String name)
{
//prompts user to accept any installation of the apk with provided name
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File
(Environment.getExternalStorageDirectory() + "/ContentManager/" + name)), "application/vnd.android.package-archive");
startActivity(intent);
//this code should execute after the install finishes
File file = new File(Environment.getExternalStorageDirectory() + "/ContentManager/"+name);
file.delete();
}
我想在安装完成后从 sd 卡中删除 apk 文件。此代码在安装开始后将其删除,从而导致安装失败。我对android相当陌生,非常感谢一些帮助。在继续该过程之前,我基本上是在尝试等待安装完成。
【问题讨论】:
-
这不是一个答案,而是更多地提醒您一种可能性,并可能为您节省时间和精力来处理可能不允许的事情。我不确定,也许这里的其他人可以确认,但我认为不允许从 Marketplace 以外的任何地方下载应用程序。
-
已经有从我设置的私人服务器下载应用程序的代码,此安装代码有效,但之后apk仍然存在,我希望将其删除。
标签: android