How to work with Android’s in-app update API?

Step 1: Add dependency (build.gradle (app)): dependencies { implementation ‘com.google.android.play:core:1.7.3′ … } Step 2: Check for update availability and start if it’s available private AppUpdateManager mAppUpdateManager; private static final int RC_APP_UPDATE = 11; In onStart() method: mAppUpdateManager = AppUpdateManagerFactory.create(this); mAppUpdateManager.registerListener(installStateUpdatedListener); mAppUpdateManager.getAppUpdateInfo().addOnSuccessListener(appUpdateInfo -> { if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE /*AppUpdateType.IMMEDIATE*/)){ try { mAppUpdateManager.startUpdateFlowForResult( appUpdateInfo, AppUpdateType.FLEXIBLE … Read more

tech