Android In-App Updates code always trigger updates

36 Views Asked by At

Here is my code.

AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(context);

Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
    Log.d(LOG_TAG, "App update?" + appUpdateInfoTask.isSuccessful()); // Line L
    
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> { // Line K
    Log.d(LOG_TAG, "APP UPDATE: checking new version... ");
    if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
            && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
            // Request the update.
            showUpdateDialog(); // my customized update popup window
        }
    });

The app version on prod is 123. I changed the version to 122, 123 or 124, the Line L always returns FALSE, and the code jumps into Line K and triggers my code(showUpdateDialog). Any ideas? What's the problem? Thanks a lot.

0

There are 0 best solutions below