0

I have an app that is device owner. It is kiosk app with pinned screen. It updates itself by downloading .apk from remote server and by installing it silently using PackageInstaller.

However, after the update completes, the app shuts down and tablet's default screen with icons is displayed (I don't want this as my app is kiosk app and it should not allow user to control the tablet).

The question is: how to restart my app once the update completes?

I already tried:

AndroidManifest.xml:

    <receiver android:name=".PackageReplacedReceiver">
        <intent-filter>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            <data android:scheme="package" />
        </intent-filter>
    </receiver>

PackageReplacedReceiver.java

public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
            ApplicationInfo app = new ApplicationInfo();
            Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage(app.packageName);
            context.startActivity(LaunchIntent);
    }
}

However, my app never restarts when the update is done.

I use compileSdkVersion 29, minSdkVersion 23, targetSdkVersion 29.

Martin Dusek
  • 1,170
  • 3
  • 16
  • 41
  • 1
    Does this answer your question? [Has anyone received Android MY\_PACKAGE\_REPLACED notifications?](https://stackoverflow.com/questions/22693894/has-anyone-received-android-my-package-replaced-notifications) – VenomVendor May 21 '20 at 21:13
  • No, removing data tag makes no difference. I also tried using PACKAGE_REMOVED, PACKAGE_ADDED, PACKAGE_REPLACED actions instead of MY_PACKAGE_REPLACED with no luck, never received anything. So, are these actions currently supported feature, should it work? – Martin Dusek May 22 '20 at 07:28
  • I recommend [ProcessPhoenix](https://github.com/JakeWharton/ProcessPhoenix), a small library by Jake Wharton. – Onik May 22 '20 at 09:20
  • you got any solution? – mantc_sdr Jul 09 '20 at 14:04

0 Answers0