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.