From 643e387d2d2802502b3d33320055bc0ee10e29e2 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Wed, 4 Oct 2023 13:58:05 +0200 Subject: [PATCH] Dismiss all notifications if user wants to sign in --- .../LicenseServiceNotificationRunnable.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/vending-app/src/main/java/com/android/vending/licensing/LicenseServiceNotificationRunnable.java b/vending-app/src/main/java/com/android/vending/licensing/LicenseServiceNotificationRunnable.java index 193c755da7..7a82341ba2 100644 --- a/vending-app/src/main/java/com/android/vending/licensing/LicenseServiceNotificationRunnable.java +++ b/vending-app/src/main/java/com/android/vending/licensing/LicenseServiceNotificationRunnable.java @@ -112,22 +112,14 @@ private void registerNotificationChannel() { } - private static class Receiver extends BroadcastReceiver { + public static final class IgnoreReceiver extends BroadcastReceiver { @Override - @CallSuper public void onReceive(Context context, Intent intent) { - // Dismiss notification + + // Dismiss ignored notification NotificationManagerCompat.from(context) .cancel(intent.getIntExtra(INTENT_KEY_NOTIFICATION_ID, -1)); - } - } - - public static final class IgnoreReceiver extends Receiver { - - @Override - public void onReceive(Context context, Intent intent) { - super.onReceive(context, intent); SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_FILE_NAME, Context.MODE_PRIVATE); @@ -143,10 +135,12 @@ public void onReceive(Context context, Intent intent) { } } - public static final class SignInReceiver extends Receiver { + public static final class SignInReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - super.onReceive(context, intent); + + // Dismiss all notifications + NotificationManagerCompat.from(context).cancelAll(); Log.d(TAG, "Starting sign in activity"); Intent authIntent = new Intent(GMS_AUTH_INTENT_ACTION);