androidkotlinpackageinstaller

Package installer dialog dismissible?


I am working so some demo app store. This app can detect deep link and install app from link. Before installing app user gets dialog (at least on Android 11 and 12) where he/she can click on Install or Cancel. Dialog is opened by PackageInstaller. I am using BroadcastReceiver to receive installation status (for example PackageInstaller.STATUS_PENDING_USER_ACTION). When user clicks on cancel or install or some error happens I receive a status.

But user can click outside of dialog. Dialog is smilingly dismissed and no status is reported back.

Is there way to get status? Or to make dialog non dismissible?

EDIT: dialog is create by PackageInstaller and I don’t have control it's properties.


Solution

  • Directly - no, but you can:

    1. Track onResume event to detect when it's closed (it requires some filtering to avoid false detection);
    2. Wrap it into some proxy activity and use startActivityForResult/onActivityResult to start that EXTRA_INTENT from STATUS_PENDING_USER_ACTION. resultCode is always 0, but you'll have an closing event at least.