com.google.android.play.core.install.model.UpdateAvailability Java Examples
The following examples show how to use
com.google.android.play.core.install.model.UpdateAvailability.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateManager.java From InAppUpdater with MIT License | 6 votes |
private void checkUpdate() { // Checks that the platform will allow the specified type of update. Log.d(TAG, "Checking for updates"); appUpdateInfoTask.addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() { @Override public void onSuccess(AppUpdateInfo appUpdateInfo) { if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(mode)) { // Request the update. Log.d(TAG, "Update available"); startUpdate(appUpdateInfo); } else { Log.d(TAG, "No Update available"); } } }); }
Example #2
Source File: UpdateManager.java From InAppUpdater with MIT License | 6 votes |
public void addUpdateInfoListener(final UpdateInfoListener updateInfoListener) { appUpdateInfoTask.addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() { @Override public void onSuccess(AppUpdateInfo appUpdateInfo) { if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) { // Request the update. Log.d(TAG, "Update available"); int availableVersionCode = appUpdateInfo.availableVersionCode(); int stalenessDays = appUpdateInfo.clientVersionStalenessDays() != null ? appUpdateInfo .clientVersionStalenessDays() : -1; updateInfoListener.onReceiveVersionCode(availableVersionCode); updateInfoListener.onReceiveStalenessDays(stalenessDays); } else { Log.d(TAG, "No Update available"); } } }); }
Example #3
Source File: CommcareFlexibleAppUpdateManager.java From commcare-android with Apache License 2.0 | 6 votes |
private void fetchAppUpdateInfo() { mAppUpdateManager.getAppUpdateInfo() .addOnSuccessListener(info -> { mAppUpdateInfo = info; mUpdateAvailability = info.updateAvailability(); mInstallStatus = info.installStatus(); publishStatus(); }) .addOnFailureListener(exception -> { mAppUpdateInfo = null; mUpdateAvailability = UpdateAvailability.UNKNOWN; mInstallStatus = InstallStatus.UNKNOWN; Logger.log(TAG, "fetchAppUpdateInfo|failed with : " + exception.getMessage()); publishStatus(); }); }
Example #4
Source File: CommcareFlexibleAppUpdateManager.java From commcare-android with Apache License 2.0 | 6 votes |
/** * Gets {@link AppUpdateState} using {@link #mUpdateAvailability} and {@link #mInstallStatus} */ private AppUpdateState getAppUpdateState() { AppUpdateState state = AppUpdateState.UNAVAILABLE; switch (mInstallStatus) { case InstallStatus.PENDING: case InstallStatus.DOWNLOADING: state = AppUpdateState.DOWNLOADING; break; case InstallStatus.DOWNLOADED: state = AppUpdateState.DOWNLOADED; break; case InstallStatus.FAILED: state = AppUpdateState.FAILED; break; } if (state == AppUpdateState.UNAVAILABLE && mUpdateAvailability == UpdateAvailability.UPDATE_AVAILABLE) { state = AppUpdateState.AVAILABLE; } return state; }
Example #5
Source File: UpdateManager.java From InAppUpdater with MIT License | 5 votes |
private void continueUpdateForImmediate() { instance.appUpdateManager .getAppUpdateInfo() .addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() { @Override public void onSuccess(AppUpdateInfo appUpdateInfo) { if (appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) { // If an in-app update is already running, resume the update. try { instance.appUpdateManager.startUpdateFlowForResult( appUpdateInfo, instance.mode, getActivity(), UpdateManagerConstant.REQUEST_CODE); } catch (IntentSender.SendIntentException e) { Log.d(TAG, "" + e.getMessage()); } } } }); }
Example #6
Source File: InAppUpdateManager.java From android-inapp-update with Apache License 2.0 | 5 votes |
/** * Check for update availability. If there will be an update available * will start the update process with the selected {@link UpdateMode}. */ private void checkForUpdate(final boolean startUpdate) { // 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(new OnSuccessListener<AppUpdateInfo>() { @Override public void onSuccess(AppUpdateInfo appUpdateInfo) { inAppUpdateStatus.setAppUpdateInfo(appUpdateInfo); if (startUpdate) { if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) { // Request the update. if (mode == UpdateMode.FLEXIBLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) { // Start an update. startAppUpdateFlexible(appUpdateInfo); } else if (appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) { // Start an update. startAppUpdateImmediate(appUpdateInfo); } Log.d(LOG_TAG, "checkForAppUpdate(): Update available. Version Code: " + appUpdateInfo.availableVersionCode()); } else if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_NOT_AVAILABLE) { Log.d(LOG_TAG, "checkForAppUpdate(): No Update available. Code: " + appUpdateInfo.updateAvailability()); } } reportStatus(); } }); }
Example #7
Source File: InAppUpdateManager.java From android-inapp-update with Apache License 2.0 | 5 votes |
/** * Checks that the update is not stalled during 'onResume()'. * However, you should execute this check at all app entry points. */ private void checkNewAppVersionState() { appUpdateManager .getAppUpdateInfo() .addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() { @Override public void onSuccess(AppUpdateInfo appUpdateInfo) { inAppUpdateStatus.setAppUpdateInfo(appUpdateInfo); //FLEXIBLE: // If the update is downloaded but not installed, // notify the user to complete the update. if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) { popupSnackbarForUserConfirmation(); reportStatus(); Log.d(LOG_TAG, "checkNewAppVersionState(): resuming flexible update. Code: " + appUpdateInfo.updateAvailability()); } //IMMEDIATE: if (appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) { // If an in-app update is already running, resume the update. startAppUpdateImmediate(appUpdateInfo); Log.d(LOG_TAG, "checkNewAppVersionState(): resuming immediate update. Code: " + appUpdateInfo.updateAvailability()); } } }); }
Example #8
Source File: MainActivity.java From VoIpUSSD with Apache License 2.0 | 5 votes |
private void checkUpdate() { appUpdateInfoTask = appUpdateManager.getAppUpdateInfo(); appUpdateInfoTask.addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() { @Override public void onSuccess(AppUpdateInfo appUpdateInfo) { showMessage("updateAvailability: " + appUpdateInfo.updateAvailability() + " isUpdateTypeAllowed: " + appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)); if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) { requestUpdate(appUpdateInfo); } } }); }
Example #9
Source File: CommcareFlexibleAppUpdateManager.java From commcare-android with Apache License 2.0 | 5 votes |
@Nullable @Override public Integer availableVersionCode() { if (mAppUpdateInfo == null || mUpdateAvailability == UpdateAvailability.UPDATE_NOT_AVAILABLE || mUpdateAvailability == UpdateAvailability.UNKNOWN) { return null; } return mAppUpdateInfo.availableVersionCode(); }
Example #10
Source File: CommcareImmediateAppUpdateManager.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void onResume(@NonNull LifecycleOwner owner) { fetchAppUpdateInfo(() -> { if (mAppUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) { startImmediateUpdate(); } }); }
Example #11
Source File: CommcareImmediateAppUpdateManager.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void startUpdate(Activity activity) { fetchAppUpdateInfo(() -> { if (mAppUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) { startImmediateUpdate(); } }); }
Example #12
Source File: InAppUpdateStatus.java From android-inapp-update with Apache License 2.0 | 4 votes |
public boolean isUpdateAvailable() { if (appUpdateInfo != null) return appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE; return false; }