自Android 4.4.2起,应用程序操作无效

时间:2015-01-15 16:09:26

标签: android installer install android-4.4-kitkat

我创建了一个应用程序和一个更新程序应用程序。 Updater App非常简单,它加载了最新版本(如果可用),然后使用以下代码安装它:

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(Uri.fromFile(new File(PATH_TO_APK)), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(intent);

它适用于所有Android版本,但在Android 4.4.2上,在权限对话框之后,它表示无法安装该应用程序。

PATH_TO_APK如下:

Environment.getExternalStorageDirectory().getPath() + "/.temp.apk";

1 个答案:

答案 0 :(得分:0)

我解决了我的问题: 在onStop()方法中,我删除下载的APK文件。在Android的早期版本中,如果出现安装对话框,则不会调用onStop()方法,但在Android 4.2.2中,该方法被调用,因此APK文件已被删除。