How to know the AppUpdateType at the origin of the DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS update availability?

大憨熊 提交于 2021-02-08 04:47:56

问题


I am currently working on an implementation of the new "in-app update" library of Google.

According to the documentation, we can prompt a "flexible" or an "immediate" UI to the user. In both case, it will launch the download of the update (blocking or not).

If during this download I kill my app and them re-launch it before the end of the download, when I ask for the "update availability" the API gives me the answer UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS.

The documentation mentions this availability only in the case of an immediate update so we have to restore the fullscreen UI with the following code :

appUpdateManager.startUpdateFlowForResult(appUpdateInfo, IMMEDIATE, this, 1000)

The matter is that I also have this availability when a flexible update is downloading and in this case I do not want to start a fullscreen downloading UI because it's a flexible update...

Is there any way to know if we are in a flexible or an immediate update when the API returns UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS as the availability ?

Thank you in advance for your help!


回答1:


The API does not return whether the update was started as an immediate or flexible flow.

If you want to make sure to resume the same flow type you had started before, you have 2 options today:

  • re-run the same logic that you ran to decide what type to start initially: if the logic is deterministic, the result will be the same and you will resume the same type of flow
  • remember what type you started explicitly (persist this information)

Note that choosing the wrong flow type when resuming is not a problem: internally they work the same way, so you can start a flexible flow and resume it as immediate and vice-versa, without any issue.

Source: I work on the Play Core SDK



来源:https://stackoverflow.com/questions/56365502/how-to-know-the-appupdatetype-at-the-origin-of-the-developer-triggered-update-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!