【问题标题】:Implementing in App Update Functionality In Android在 Android 中实现应用程序更新功能
【发布时间】:2019-10-11 06:08:47
【问题描述】:

我已按照下面提到的步骤集成应用内更新。

1) 检查更新可用性

  // Creates instance of the manager.
  val appUpdateManager = AppUpdateManagerFactory.create(context)

  // Returns an intent object that you use to check for an update.
  val appUpdateInfoTask = appUpdateManager.appUpdateInfo

 // Checks that the platform will allow the specified type of update.
 appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
 if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE

  // For a immediate update, use AppUpdateType.IMMEDIATE
  && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)
) {
   // notify user that there is an available update
 }
}

2)如果有更新则触发更新流程

appUpdateManager.startUpdateFlowForResult(

// Pass the intent that is returned by 'getAppUpdateInfo()'.
   appUpdateInfo,

// Or 'AppUpdateType.FLEXIBLE' for flexible updates.
   AppUpdateType.IMMEDIATE,

// The current activity making the update request.
   this,

// Include a request code to later monitor this update request.
   MY_REQUEST_CODE
)

第一步,我们检查是否有更新,更新是即时的还是灵活的。

我们在哪里指定我们将在第一步中获得的更新类型?

我的意思是说我必须在哪里指定我当前的更新是否是强制更新的即时更新?

【问题讨论】:

    标签: android app-update in-app-update


    【解决方案1】:

    我已将其用于强制更新或稍后更新以进行应用更新,这对我有用。

    我使用的是使用 firebase 进行应用更新

    https://readyandroid.wordpress.com/force-app-update-androidfirebase/

    【讨论】:

      猜你喜欢
      • 2015-06-13
      • 2013-10-09
      • 1970-01-01
      • 2016-09-10
      • 1970-01-01
      • 1970-01-01
      • 2018-04-13
      • 1970-01-01
      • 2023-04-05
      相关资源
      最近更新 更多