Fix for Samsung too many alarms issue. #1873
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.