Reputation: 21
I'm trying to implement an in-app update-dialog for my android app written in java.
The code snipped to check if an update is available, is taken from the android developer page. It's called in the onResume() method of the the Main activity.
private void checkForUpdate() {
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);
// Returns an intent object that you use to check for an update.
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
// Checks that the platform will allow the specified type of update.
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
Log.d(TAG, "AppUpdateInfo: " + appUpdateInfo);
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
// can be changed to AppUpdateType.INTERMEDIATE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
// Request the update.
try {
appUpdateManager.startUpdateFlowForResult(
// Pass the intent that is returned by 'getAppUpdateInfo()'.
appUpdateInfo,
// Or 'AppUpdateType.FLEXIBLE' for flexible updates.
AppUpdateType.IMMEDIATE,
// The current activity making the update request.
this,
// Include a request code to later monitor this update request.
APP_UPDATE_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
});
}
I release new app versions through the Google Play Console. There are two closed test tracks:
When printing the AppUpdateInfo into the Logcat of a developer device, the availableVersionCode is 88. At the same time the current version (105) appears in the Google Play Store.
D/MainActivity: AppUpdateInfo: AppUpdateInfo{packageName=package.app, availableVersionCode=88, updateAvailability=1, installStatus=0, clientVersionStalenessDays=null, updatePriority=0, bytesDownloaded=0, totalBytesToDownload=0, additionalSpaceRequired=0, assetPackStorageSize=0, immediateUpdateIntent=null, flexibleUpdateIntent=null, immediateDestructiveUpdateIntent=null, flexibleDestructiveUpdateIntent=null}
There has been a version 88 in the past since the versions are incremented by 1, but currently only version 105 and 99 are live.
Now I am wondering why the AppUpdateInfo is not receiving the latest version 105. As mentioned before, the updates are made through the Google Play Console. My guess would be, that the in-app update function receives update infos that are commited through the Google Play Developer API only.
Has anyone experience the same issue and can confirm my guess? Any help is greatly appreciated.
Upvotes: 2
Views: 520