2

We have a process for allowing our users to manually update the application, because our devices do not have any app store. We download the apk from our servers and run:

updateIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
updateIntent.setData(contentUri);
updateIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

with the contentUri pointing to the location of our stored APK. As the installation is running, the app closes. Then, the following screen appears on completion:

We restart our app immediately when we receive a MY_PACKAGE_REPLACED intent. The issue is that this screen remains in the background.

How can I programmatically dismiss it?

I have tried:

// Dismiss all system ui messages
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);

but it does not work for this type of dialog

Code Wiget
  • 1,540
  • 1
  • 23
  • 35

2 Answers2

1

Try to add EXTRA_RETURN_RESULT flag:

updateIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
sdex
  • 3,169
  • 15
  • 28
0

When your App is installing/updating it come in stop state, this is the same state when user go to settings and force stop your app. So no service or BroadcastReceiver will work as your app will not be running.

what I suggest you to create 1 more app which will listen to APP INSTALLATIONS using BroadcastReceiver and do actions related to that, like whenever the user updates your app using APK it will open the app after installation.

Check this answer

Hope this will help!

Rahul Gaur
  • 1,661
  • 1
  • 13
  • 29
  • We are successfully restarting the app. That is not the issue. The issue is that the activity view stays in the background. – Code Wiget Dec 11 '19 at 13:26