简体   繁体   English

自Android 4.4.2起,应用程序操作不起作用

[英]App operations not working since Android 4.4.2

I've created an App and an Updater App. 我已经创建了一个应用程序和一个更新程序应用程序。 The Updater App is very simple, it loads the newest version, if available, and then installs it with the following code: 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);

It's working well on all Android versions, but on Android 4.4.2, after the permissons dialog, it says that the App could not be installed. 它在所有Android版本上都能正常运行,但在Android 4.4.2上,在“权限”对话框后,它表示无法安装该应用程序。

The PATH_TO_APK is the following: PATH_TO_APK是以下内容:

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

I solved my problem: In the onStop() method, I delete the downloaded APK file. 我解决了我的问题:在onStop()方法中,我删除了下载的APK文件。 In previous versions of Android, the onStop() method was not called if the install dialog appears, but in Android 4.2.2, the method is called and so the APK file was deleted. 在早期版本的Android中,如果出现安装对话框,则不会调用onStop()方法,但是在Android 4.2.2中,将调用该方法,因此会删除APK文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM