AndroidScheduleMode
How Android schedules the alarm that delivers a notification.
Inexact modes need no special access but may deliver some minutes late, as Android batches alarms to save power. Exact modes deliver on time and need exact-alarm access:
Declare it in
pyproject.toml:[tool.flet.android.permission]"android.permission.SCHEDULE_EXACT_ALARM" = true- On Android 14+, the access is off until the user turns it on in system
settings. Check it with
Notifications.can_schedule_exact_alarmsand open that settings screen withNotifications.request_exact_alarm_permission. - Scheduling in an exact mode without the access raises
NotificationPermissionException. - The user or the system can revoke the access at any time. Android then stops the app and cancels its future exact alarms, so those notifications are not delivered. Check the access when the app starts and reschedule once it is granted again. See Android's exact alarm permission documentation.
- Alarm-clock and calendar apps can declare
"android.permission.USE_EXACT_ALARM"instead. Android grants it without the user's action and it can't be revoked, but Google Play allows it only for those kinds of apps.
Delivery in every mode remains subject to Android's alarm quotas and background-execution restrictions. Some manufacturers, such as Xiaomi, Huawei and Samsung, also stop apps in the background, so scheduled notifications may not arrive until the user exempts the app; see Don't kill my app!. Samsung devices have been reported to accept at most 500 scheduled alarms per app.
Inherits: enum.Enum
Properties
ALARM_CLOCK- Schedules an exact alarm-clock notification that can run during idle mode.EXACT- Schedules for the requested time, with deferral possible during idle mode.EXACT_ALLOW_WHILE_IDLE- Schedules an exact alarm that can execute during low-power idle mode.INEXACT- Schedules approximately at the requested time, allowing idle-mode deferral.INEXACT_ALLOW_WHILE_IDLE- Schedules approximately at the requested time, including during idle mode.
Properties
ALARM_CLOCKclass-attributeinstance-attribute
Schedules an exact alarm-clock notification that can run during idle mode.
Uses Android's alarm-clock mechanism and can appear in its next-alarm UI. Requires exact-alarm access.
EXACTclass-attributeinstance-attribute
Schedules for the requested time, with deferral possible during idle mode.
Requires exact-alarm access.
EXACT_ALLOW_WHILE_IDLEclass-attributeinstance-attribute
Schedules an exact alarm that can execute during low-power idle mode.
Requires exact-alarm access.
INEXACTclass-attributeinstance-attribute
Schedules approximately at the requested time, allowing idle-mode deferral.
Does not require exact-alarm access.
INEXACT_ALLOW_WHILE_IDLEclass-attributeinstance-attribute
Schedules approximately at the requested time, including during idle mode.
Does not require exact-alarm access; Android may batch or delay delivery. This is
the default of Notifications.schedule and
Notifications.periodically_show.