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);
});
}
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());
}
});
}
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());
}
});
}
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());
}
});
}
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());
}
});
}
Aggregations