@@ -259,30 +259,33 @@ protected void onResume() {
259259 AppUsageNotificationsManager appUsageNotificationsManager = new AppUsageNotificationsManager (this );
260260 appUsageNotificationsManager .scheduleAppUsageCheck ();
261261 appUpdateNotificationsManager .checkAndSendUpdateNotification ();
262- checkForFlexibleOrImmediateUpdate ();
262+ checkForImmediateUpdate ();
263263 }
264264
265- private void checkForFlexibleOrImmediateUpdate () {
266- appUpdateManager .getAppUpdateInfo ().addOnSuccessListener (appUpdateInfo -> {
267- boolean updateAvailable = appUpdateInfo .updateAvailability () == UpdateAvailability .UPDATE_AVAILABLE ;
268- if (updateAvailable ) {
269- int priority = appUpdateInfo .updatePriority ();
270- if (priority >= 3 && appUpdateInfo .isUpdateTypeAllowed (AppUpdateType .IMMEDIATE )) {
271- startImmediateUpdate (appUpdateInfo );
272- } else if (appUpdateInfo .isUpdateTypeAllowed (AppUpdateType .FLEXIBLE )) {
273- startFlexibleUpdate (appUpdateInfo );
274- }
275- }
276- })
277- .addOnFailureListener (e -> {
278- if (!BuildConfig .DEBUG ) {
279- Snackbar .make (
280- findViewById (android .R .id .content ),
281- getString (R .string .snack_general_error ),
282- Snackbar .LENGTH_LONG
283- ).show ();
284- }
285- });
265+ private void checkForImmediateUpdate () {
266+ appUpdateManager
267+ .getAppUpdateInfo ()
268+ .addOnSuccessListener (
269+ appUpdateInfo -> {
270+ boolean updateAvailable =
271+ appUpdateInfo .updateAvailability ()
272+ == UpdateAvailability .UPDATE_AVAILABLE ;
273+ if (updateAvailable
274+ && appUpdateInfo .isUpdateTypeAllowed (
275+ AppUpdateType .IMMEDIATE )) {
276+ startImmediateUpdate (appUpdateInfo );
277+ }
278+ })
279+ .addOnFailureListener (
280+ e -> {
281+ if (!BuildConfig .DEBUG ) {
282+ Snackbar .make (
283+ findViewById (android .R .id .content ),
284+ getString (R .string .snack_general_error ),
285+ Snackbar .LENGTH_LONG )
286+ .show ();
287+ }
288+ });
286289 }
287290
288291 private void startImmediateUpdate (AppUpdateInfo appUpdateInfo ) {
@@ -293,14 +296,6 @@ private void startImmediateUpdate(AppUpdateInfo appUpdateInfo) {
293296 );
294297 }
295298
296- private void startFlexibleUpdate (AppUpdateInfo appUpdateInfo ) {
297- appUpdateManager .startUpdateFlowForResult (
298- appUpdateInfo ,
299- updateActivityResultLauncher ,
300- AppUpdateOptions .newBuilder (AppUpdateType .FLEXIBLE ).build ()
301- );
302- }
303-
304299 private void registerInstallStateListener () {
305300 installStateUpdatedListener = state -> {
306301 if (state .installStatus () == InstallStatus .DOWNLOADED ) {
0 commit comments