使用InApp Update API模式灵活

问题描述

我正在使用In App Update API,使用以下代码将更新类型设置为“灵活”

                    appUpdateManager.startUpdateFlowForResult(
                            appUpdateInfo,AppUpdateType.FLEXIBLE,this,APP_UPDATE_REQUEST_CODE)

其中更新类型以AppUpdateType.FLEXIBLE的形式提供。 它展示了正确的UI,并在其中提供了供用户选择“更新”或“不,谢谢”的选项。 如下图所示。

enter image description here

但是,单击更新实际上会显示全屏用户界面,其进度条通常与立即更新相关联,而不是在后台执行更新。

使用播放代码SDK版本1.8.X

// Rate this app
// So,make sure you also include that repository in your project's build.gradle file.
implementation 'com.google.android.play:core:1.8.0'
// For Kotlin users also import the Kotlin extensions library for Play Core:
implementation 'com.google.android.play:core-ktx:1.8.1'

有人知道为什么会这样吗?

预先感谢。

解决方法

也许你的问题是

override fun onResume() {
    super.onResume()
    appUpdateManager
        .appUpdateInfo
        .addOnSuccessListener {
            // If an in-app update is already running,resume the update.
            if (it.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS)
                startUpdate(it,AppUpdateType.IMMEDIATE) // <<-- !!HERE!!
            // If the update is downloaded but not installed,notify the user to complete the update.
            if (it.installStatus == InstallStatus.DOWNLOADED) {
                nav_progress_download.hide()
                popupSnackbarForCompleteUpdate()
            }
        }
}

单击更新按钮时,将调用onResume。 并且AppUpdateType.FLEXIBLE的updateAvailability()与UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS相同

检查此...

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

https://issuetracker.google.com/issues/153785560