Class AppUpdates

java.lang.Object
com.codename1.system.AppUpdates

public final class AppUpdates extends Object

Checks whether a newer version of the app is in the store and helps the user install it.

On Android the check uses Google Play in-app updates, which the build adds when this class is referenced. #startUpdate(boolean) then shows Play's own flexible or immediate update flow. Everywhere else the check asks the App Store lookup service for the version published under the bundle id, and #startUpdate(boolean) opens the store page.

AppUpdates.check(new SuccessCallback<AppUpdates.UpdateInfo>() {
    public void onSucess(AppUpdates.UpdateInfo info) {
        if (info.isUpdateAvailable()) {
            AppUpdates.startUpdate(false);
        }
    }
});
  • Method Details

    • setProvider

      public static void setProvider(AppUpdates.Provider provider)

      Registers the platform provider. Internal: for ports and generated code, which inject the platform implementation here; applications do not call it.

      Parameters
      • provider: the provider, or null for the store lookup
    • check

      public static void check(SuccessCallback<AppUpdates.UpdateInfo> callback)

      Checks for a newer version. The callback is called on the EDT; on a failure it gets an UpdateInfo with no update and no version.

      Parameters
      • callback: receives the result
    • startUpdate

      public static boolean startUpdate(boolean immediate)

      Starts the update: Play's update flow on Android, or the store page that an earlier #check(SuccessCallback) found.

      Parameters
      • immediate: on Android, true for Play's blocking flow; ignored elsewhere
      Returns

      true when a flow or store page was opened

    • compareVersions

      public static int compareVersions(String a, String b)

      Compares two dotted version strings numerically.

      Parameters
      • a: a version such as 1.10.2

      • b: another version

      Returns

      a negative number, zero or a positive number as a is older, equal or newer than b