Hello folks! Is this a good place to ask questions...
# android
s
Hello folks! Is this a good place to ask questions about Android's in-app update library? https://developer.android.com/guide/playcore/in-app-updates/kotlin-java
not kotlin but kotlin colored 2
j
You will get a lot of "not kotlin" badges, but i'm sure somebody will help you out eventually 🙂
s
Hahaha! Just want to be sure about not getting that badge xD
Okay so since we are here, I have a quick question. Im trying to build a feature in which I can start an update flow (
Immediate
) based of a particular condition. All the releases that I create on
play console
would be an
"optional update"
but on the client side, I would want to trigger a forced update flow based on a condition. Is this theoretically possible though? Something like this.
Copy code
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
    if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
        // Request the update.
        if(shouldForceUpdateForTheUser) {
           appUpdateManager.startUpdateFlowForResult(
               appUpdateInfo,
               activityResultLauncher,
               AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build()) // NOTE - I trigger a forced update
           )
        }
    }
}
🧵 1
j
You can trigger immediate update which will show update screen to the user, but it won't force the user to update. If you really want to force update you have to lock the application when the update is available and you really need to (i think this should be limited to a scenario where you REALLY HAVE TO force the update due to some security flaw or when you retire some old api)
So you can detect that the update is available, you can somehow confirm that user is on too old version and just lock out user from using the app unless he goes through the update
i implemented that flow in 2 projects, but we never used that. We just kept that for the emergency
s
Thanks for responding @Jakub Syty When you say
but it won't force the user to update.
it means that the update dialog/screen would be shown to the user and if they dont update, they are thrown outta the app right? They wouldnt be able to use the app like how you do with a flexible update.
j
user can just navigate back from that screen to your app. immediate update is just a suggestion for user that he should do that, but the in-app update sdk is not forcing anything on user
flexible update is flexible just because you can download the update in the background while using the app
so if you want user to be locked until the update - you have to implement that yourself
s
Understood. Thanks for clarifying. Guess ill just do something here :
Copy code
if (resultCode == RESULT_CANCELED) {
            // This block of code is executed if user clicks cancel button from the in-app update screen or press the hardware back button.
}
👍🏻 1