What is the alternative to get callback for startUpdateFlowForResult in InAppUpdates instead of onActivityResult since it is deprecated?
An updated Google doc has been made available: https://developer.android.com/guide/playcore/in-app-updates/kotlin-java
You can launch the update like this:
appUpdateManager.startUpdateFlowForResult(
// Pass the intent that is returned by 'getAppUpdateInfo()'.
appUpdateInfo,
// an activity result launcher registered via registerForActivityResult
activityResultLauncher,
// Or pass 'AppUpdateType.FLEXIBLE' to newBuilder() for
// flexible updates.
AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build()
)
And the activityResultLauncher is set up in your Activity like this:
private val activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result ->
val resultCode = result.resultCode
when {
resultCode == Activity.RESULT_OK -> {
Log.v("MyActivity", "Update flow completed!")
}
resultCode == Activity.RESULT_CANCELED -> {
Log.v("MyActivity", "User cancelled Update flow!")
}
else -> {
Log.v("MyActivity", "Update flow failed with resultCode:$resultCode")
}
}
}
We have to wait for Google Play team to migrate away from the deprecated APIs. You can follow this issue on Google's Issue Tracker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With