My app, already published on Google Play and currently targetting Android 12, is an alarm clock app. In the latest release, I have used the SCHEDULE_EXACT_ALARM
permission and also handled checking and requesting this permission at runtime, as required.
Upon checking the behaviour change for Android 13, I found that there is a new permission USE_EXACT_ALARM
which has very restrictive use cases as listed here. My app is an alarm clock app, and hence it qualifies to use this permission. (An advantage of using this permission is that the system automatically grants it, and it cannot be revoked by the user.)
I added this permission to the AndroidManifest.xml
file and removed the SCHEDULE_EXACT_ALARM
permission. However, Android Studio gives me a lint warning on the method alarmManager.setAlarmClock(...)
:
This is what the warning reads:
Setting Exact alarms with
setAlarmClock
requires theSCHEDULE_EXACT_ALARM
permission or power exemption from user; it is intended for applications where the user knowingly schedules actions to happen at a precise time such as alarms, clocks, calendars, etc. Check out the javadoc on this permission to make sure your use case is valid.
The Android Developers website says that I have the option to declare either of the permissions based on my use case. However, Android lint tells me that I should declare SCHEDULE_EXACT_ALARM
irrespective of whether I have already declared USE_EXACT_ALARM
.
What should I do? Follow the website and suppress lint?
USE_EXACT_ALARM
by following the website. It seems that this supersedes theSCHEDULE_EXACT_ALARM
permission. – Windsor