I'm running an android app to be the only app to run on the system, so, when boot-completed I launch the app and prevent the user from exiting it for any reason(which made me disable both navigation status bars).
Then, to achieve an update to the app, I look if there is a new one, and if so, I run a background task to download the new update from the sftp server using jsch, and when the app finish downloading, I install the apk using ACTION_VIEW
intent:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/update_app.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
The problem here is when the installation complete, the default android screen appears:
and this gives the user the option to choose Done || Open, and for sure if the user choose Done that will lead to close the window and the app is already closed now as it is updated, so it takes the user to the system UI which is not welcomed at all.
keep in mind that I can't open the app programmatically as when install the update it uninstall the old-version, so I've to do one of the two options which I don't know how to achieve any:
Force the app to open by default after the installation finished.
Change the system install finish screen or override it's buttons actions.