Search code examples
androidinstallationandroid-4.4-kitkat

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:

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.

The PATH_TO_APK is the following:

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

Solution

  • I solved my problem: In the onStop() method, I delete the downloaded APK file. 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.