com.google.android.play.core.tasks.OnSuccessListener Java Examples
The following examples show how to use
com.google.android.play.core.tasks.OnSuccessListener.
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: UpdateManager.java From InAppUpdater with MIT License | 5 votes |
private void continueUpdateForFlexible() { instance.appUpdateManager .getAppUpdateInfo() .addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() { @Override public void onSuccess(AppUpdateInfo appUpdateInfo) { // If the update is downloaded but not installed, // notify the user to complete the update. if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) { Log.d(TAG, "An update has been downloaded"); instance.popupSnackbarForCompleteUpdate(); } } }); }
Example #4
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 #5
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 #6
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 #7
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 #8
Source File: MainActivity.java From VoIpUSSD with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); appUpdateManager.getAppUpdateInfo().addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() { @Override public void onSuccess(AppUpdateInfo result) { if (result.installStatus() == InstallStatus.DOWNLOADED) { notifyUser(); } } }); }
Example #9
Source File: MainActivity.java From AndroidAppBundleDemo with Apache License 2.0 | 5 votes |
public void loadFeatureOne() { // Builds a request to install the feature1 module SplitInstallRequest request = SplitInstallRequest .newBuilder() // You can download multiple on demand modules per // request by invoking the following method for each // module you want to install. .addModule("feature1") .build(); // Begin the installation of the feature1 module and handle success/failure splitInstallManager .startInstall(request) .addOnSuccessListener(new OnSuccessListener<Integer>() { @Override public void onSuccess(Integer integer) { // Module download successful Intent intent = new Intent().setClassName(getPackageName(), "com.bapspatil.feature1.FeatureOneActivity"); startActivity(intent); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(Exception e) { // Module download failed; handle the error here Toast.makeText(getApplicationContext(), "Couldn't download feature1: " + e.getMessage(), Toast.LENGTH_LONG).show(); } }); }
Example #10
Source File: MainActivity.java From AndroidAppBundleDemo with Apache License 2.0 | 5 votes |
public void loadFeatureTwo() { // Builds a request to install the feature1 module SplitInstallRequest request = SplitInstallRequest .newBuilder() // You can download multiple on demand modules per // request by invoking the following method for each // module you want to install. .addModule("feature2") .build(); // Begin the installation of the feature1 module and handle success/failure splitInstallManager .startInstall(request) .addOnSuccessListener(new OnSuccessListener<Integer>() { @Override public void onSuccess(Integer integer) { // Module download successful Intent intent = new Intent().setClassName(getPackageName(), "com.bapspatil.feature2.FeatureTwoActivity"); startActivity(intent); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(Exception e) { // Module download failed; handle the error here Toast.makeText(getApplicationContext(), "Couldn't download feature2: " + e.getMessage(), Toast.LENGTH_LONG).show(); } }); }