3

My app has Auto-Update feature. I install apk file using this code:

Uri uri;
Intent intent;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
    uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file);
    intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
    intent.setData(uri);
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else {
    uri = Uri.fromFile(file);
    intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(uri, "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

context.startActivity(intent);

The problem is that in api 24 or higher Android package installer doesn't ask to click on "Done" or "Open" after updating completed and dialog will be closed without any questions or any messages.

I need package installer ask what to do like

This Picture.

Alireza Noorali
  • 3,129
  • 2
  • 33
  • 80
  • Why is this a problem? – CommonsWare Dec 18 '17 at 12:35
  • @CommonsWare: User tries to update app and suddenly the dialog closes without any questions or any messages. it is not expected. User must inform about completing update process and he/she should have choices to open the app or not. – Alireza Noorali Dec 18 '17 at 12:57
  • AFAIK, Google changed the flow to not show that screen. That's Google's decision to make, since it is their operating system. – CommonsWare Dec 18 '17 at 13:10
  • @CommonsWare: So you mean there is really no way and this is a waste of time to try to find a solution? – Alireza Noorali Dec 18 '17 at 13:25
  • AFAIK, you have no control over the behavior, if that is what you mean. The behavior of `ACTION_INSTALL_PACKAGE` and `ACTION_VIEW` are up to their implementers (Google, and secondarily device manufacturers/custom ROM developers). There is no `EXTRA_PLEASE_SHOW_OPEN_OR_DONE_ACTIVITY` that I know of in the Android SDK. The behavior that you cite is for the devices that you tested; other devices can behave differently. – CommonsWare Dec 18 '17 at 13:27
  • @CommonsWare: But [CafeBazzar Iranian App Market](http://cafebazaar.ir/) has done it. when you update an app in _CafeBazaar_, the old behavior occures on Android 7.0 and you have two choices to click on **"Done"** or **"Open"**. – Alireza Noorali Dec 18 '17 at 13:58
  • Did you found any solution? – H.Fa8 May 27 '20 at 07:51
  • @H.Fa8 No, I didn't! What about you? – Alireza Noorali May 30 '20 at 10:46
  • @AlirezaNoorali You should use debug version when debug version installed before, and if release version installed you should use release version for update. – H.Fa8 May 31 '20 at 07:37
  • @H.Fa8 I think you didn't read the question carefully. The subject of the question is something else – Alireza Noorali Jun 01 '20 at 14:13

0 Answers0