Search in sources :

Example 1 with AppUpdateInfo

use of com.google.android.play.core.appupdate.AppUpdateInfo in project capacitor-app-update by robingenz.

the class AppUpdatePlugin method getAppUpdateInfo.

@PluginMethod
public void getAppUpdateInfo(PluginCall call) {
    Task<AppUpdateInfo> appUpdateInfoTask = this.appUpdateManager.getAppUpdateInfo();
    appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
        this.appUpdateInfo = appUpdateInfo;
        PackageInfo pInfo;
        try {
            pInfo = this.getPackageInfo();
        } catch (PackageManager.NameNotFoundException e) {
            call.reject(ERROR_GET_APP_INFO_FAILED);
            return;
        }
        JSObject ret = new JSObject();
        ret.put("currentVersion", String.valueOf(pInfo.versionCode));
        ret.put("availableVersion", String.valueOf(appUpdateInfo.availableVersionCode()));
        ret.put("updateAvailability", appUpdateInfo.updateAvailability());
        ret.put("updatePriority", appUpdateInfo.updatePriority());
        ret.put("immediateUpdateAllowed", appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE));
        ret.put("flexibleUpdateAllowed", appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE));
        Integer clientVersionStalenessDays = appUpdateInfo.clientVersionStalenessDays();
        if (clientVersionStalenessDays != null) {
            ret.put("clientVersionStalenessDays", clientVersionStalenessDays);
        }
        ret.put("installStatus", appUpdateInfo.installStatus());
        call.resolve(ret);
    });
    appUpdateInfoTask.addOnFailureListener(failure -> {
        String message = failure.getMessage();
        call.reject(message);
    });
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) JSObject(com.getcapacitor.JSObject) AppUpdateInfo(com.google.android.play.core.appupdate.AppUpdateInfo) PluginMethod(com.getcapacitor.PluginMethod)

Example 2 with AppUpdateInfo

use of com.google.android.play.core.appupdate.AppUpdateInfo in project alpha-wallet-android by AlphaWallet.

the class UpdateUtils method pushUpdateDialog.

public static void pushUpdateDialog(Activity context) {
    AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(context);
    Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
    appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
        if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
            appUpdateManager.startUpdateFlow(appUpdateInfo, context, AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build());
        }
    });
}
Also used : AppUpdateInfo(com.google.android.play.core.appupdate.AppUpdateInfo) AppUpdateManager(com.google.android.play.core.appupdate.AppUpdateManager)

Example 3 with AppUpdateInfo

use of com.google.android.play.core.appupdate.AppUpdateInfo in project alpha-wallet-android by AlphaWallet.

the class UpdateUtils method checkForUpdates.

public static void checkForUpdates(Activity context, FragmentMessenger messenger) {
    AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(context);
    Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
    appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
        if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
            messenger.updateReady(appUpdateInfo.availableVersionCode());
        }
    });
}
Also used : AppUpdateInfo(com.google.android.play.core.appupdate.AppUpdateInfo) AppUpdateManager(com.google.android.play.core.appupdate.AppUpdateManager)

Example 4 with AppUpdateInfo

use of com.google.android.play.core.appupdate.AppUpdateInfo in project Ethernity-Wallet-Android by kris-krytech.

the class UpdateUtils method pushUpdateDialog.

public static void pushUpdateDialog(Activity context) {
    AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(context);
    Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
    appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
        if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
            appUpdateManager.startUpdateFlow(appUpdateInfo, context, AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build());
        }
    });
}
Also used : AppUpdateInfo(com.google.android.play.core.appupdate.AppUpdateInfo) AppUpdateManager(com.google.android.play.core.appupdate.AppUpdateManager)

Example 5 with AppUpdateInfo

use of com.google.android.play.core.appupdate.AppUpdateInfo in project Ethernity-Wallet-Android by kris-krytech.

the class UpdateUtils method checkForUpdates.

public static void checkForUpdates(Activity context, FragmentMessenger messenger) {
    AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(context);
    Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
    appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
        if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
            messenger.updateReady(appUpdateInfo.availableVersionCode());
        }
    });
}
Also used : AppUpdateInfo(com.google.android.play.core.appupdate.AppUpdateInfo) AppUpdateManager(com.google.android.play.core.appupdate.AppUpdateManager)

Aggregations

AppUpdateInfo (com.google.android.play.core.appupdate.AppUpdateInfo)5 AppUpdateManager (com.google.android.play.core.appupdate.AppUpdateManager)4 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 JSObject (com.getcapacitor.JSObject)1 PluginMethod (com.getcapacitor.PluginMethod)1