Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Samsung too many alarms issue. #1873

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KPalvolg
Copy link

@KPalvolg KPalvolg commented Feb 6, 2020

Fixes "too many alarms (500)" issue on Samsung devices after cancelling and scheduling notifications (#1753 and #1701).

Creating the an Intent, when cancelling an existing notification, that matches the one that was used to schedule the notification. This cancels both the PendingIntent and the scheduled Alarm and prevents cancelled scheduled alarms from building up.
See: https://developer.android.com/reference/android/app/AlarmManager?hl=en#cancel(android.app.PendingIntent)
and https://developer.android.com/reference/android/content/Intent.html?hl=en#filterEquals(android.content.Intent)

Samsung has a 500 cap on alarms scheduled from the same uid. Cancelling notifications removed the PendingIntent, but not the Alarm (can be confirmed using the adb shell dumpsys alarm command). This could fill the list of alarms from the app with alarms that can't trigger, causing new notifications to be blocked from being scheduled.

The adb shell dumpsys alarm command can be used to confirm that the number of alarms from your app decrease appropriately after cancelling scheduled notifications. If updating, to be able to schedule new notifications, your app will have to be force stopped from the settings to remove any existing notifications that did not get cleared properly.

Fixes "too many alarms (500)" issue on Samsung devices after cancelling and
scheduling notifications, by creating the same Intent when cancelling an
existing notification, just like the one that was used to create the notification.
This clears both the PendingIntent and the scheduled Alarm.

Uses TriggerReceiver.class as the default receiver.

Use the "adb shell dumpsys alarm" command to confirm that the number of
alarms don't increase from your app, when cancelling and scheduling
notifications. Previously the Alarm remained in the alarm list when cancelling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant