Skip to content

Instantly share code, notes, and snippets.

@sismetanin
Last active March 30, 2020 02:31
Show Gist options
  • Save sismetanin/861a55769dcb637db220e53cfde44fc1 to your computer and use it in GitHub Desktop.
Save sismetanin/861a55769dcb637db220e53cfde44fc1 to your computer and use it in GitHub Desktop.
// Create instance of the IAU manager.
val appUpdateManager = AppUpdateManagerFactory.create(context)
// Add state listener to app update info task.
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
// If there is an update available, prepare to promote it.
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
// ...
}
// If the process of downloading is finished, start the completion flow.
if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
// ...
}
}
.addOnFailureListener { e ->
// Handle the error.
}
@kada-zaouak
Copy link

// إنشاء مثيل لمدير IAU.
val appUpdateManager = AppUpdateManagerFactory .create (سياق)

// إضافة مستمع حالة إلى مهمة معلومات تحديث التطبيق.
appUpdateManager.appUpdateInfo.addOnSuccessListener {appUpdateInfo - >
// إذا كان هناك تحديث متاح ، فاستعد للترويج له.
if (appUpdateInfo.updateAvailability () == UpdateAvailability . UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed ( AppUpdateType . FLEXIBLE )) {
// ...
}}

// إذا انتهت عملية التنزيل ، ابدأ تدفق الإكمال.
if (appUpdateInfo.installStatus () ==  InstallStatus . تم التنزيل ) {
    // ...
}}

}}
.addOnFailureListener {e - >
// معالجة الخطأ.
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment