I see the following warning in PlayStore:
Your use of exact alarms is causing your app to crash for some Android users
Your app schedules exact alarms without checking whether the SCHEDULE_EXACT_ALARM permission has been granted. This is causing your app to crash for users on Android 14 because the permission is no longer granted by default.
In most cases, alternative methods of scheduling work or inexact alarms are more appropriate. If your use of exact alarms is justified, update your app so that it checks this permission is granted before scheduling.
Although, I very specifically only trigger an INEXACT alarm in the following manner:
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val alarmIntent =
Intent(context, MediaDownloadAlarmReceiver::class.java).let { intent ->
PendingIntent.getBroadcast(
context,
0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
}
val calendar =
Calendar.getInstance().apply {
timeInMillis = System.currentTimeMillis()
set(Calendar.HOUR_OF_DAY, 5)
set(Calendar.MINUTE, 0)
}
// Set the alarm to start at approximately 5:00 a.m.
alarmManager.setInexactRepeating(
AlarmManager.RTC_WAKEUP,
calendar.timeInMillis,
AlarmManager.INTERVAL_DAY,
alarmIntent)
Once the alarm triggers, I schedule a one time worker request:
override fun onReceive(context: Context?, intent: Intent?) {
if (context != null) {
MediaDownloadWorker.scheduleOneTimeRequest(
context = context,
source = "background_process")
}
}
Any idea what am I missing?