1

I install apk file from folder programatically in such way:

File file = new File(apkFilePath);
    if (file.exists()) {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("file://" + apkFilePath),
                    "application/vnd.android.package-archive");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } catch (Exception e) {
            Log.d(TAG, "install error: " + e.toString());
        }
    } else {
        Log.d(TAG, "File doesn't exist ");
    }

When dialog appear there are two buttons "Install" and "Cancel". I need to catch cancel event. I try to register broadcast receiver but can't find appropriate event for cancel install action.

Evgeniy Rechkov
  • 465
  • 4
  • 15
  • I personally haven't tried what you do but I assume it's not cancel that you want to detect but your app installation for there may be other failure reasons that is not cancel (like lack of disk space). And you can register for that registration/update event. See this question https://stackoverflow.com/questions/10297149/android-listen-for-app-installed-upgraded-broadcast-message – mhenryk Aug 26 '17 at 08:21

0 Answers0