From 87342782d797a26a4d5b4c7db352e83bbae6b2b6 Mon Sep 17 00:00:00 2001 From: sk Date: Mon, 16 Jan 2023 18:32:42 +0100 Subject: [PATCH] fix clearing notifications closes sk22#292 --- .../org/joinmastodon/android/fragments/HomeFragment.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java index 30b38ffbf..8425ad236 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java @@ -5,6 +5,7 @@ import android.app.NotificationManager; import android.graphics.Outline; import android.os.Build; import android.os.Bundle; +import android.service.notification.StatusBarNotification; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -233,7 +234,11 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene ((NotificationsFragment) newFragment).loadData(); // TODO make an interface? NotificationManager nm=getActivity().getSystemService(NotificationManager.class); - nm.cancel(accountID, PushNotificationReceiver.NOTIFICATION_ID); + for (StatusBarNotification notification : nm.getActiveNotifications()) { + if (accountID.equals(notification.getTag())) { + nm.cancel(accountID, notification.getId()); + } + } } }