onReceive() is called by all other API levels but for some reason is not called by API 33.
As far as I understand as of API 31 SCHEDULE_EXACT_ALARM permission is needed and auto allowed however after API 33 no longer auto set as true.
However as of API 33 USE_ALARM is available which is allowed from install and SCHEDULE_EXACT_ALARM is no longer needed in this case.
my permissions:
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"
android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
alarm manager:
fun schedule(context: Context) {
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val intent = Intent(context, AlarmReceiver::class.java)
intent.putExtra("once", once)
intent.putExtra("vibrate", vibrate)
intent.putExtra("shake", shake)
intent.putExtra("snooze", snooze)
val alarmPendingIntent = PendingIntent.getBroadcast(
context,
alarmId, intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
val calendar: Calendar = Calendar.getInstance()
calendar.timeInMillis = System.currentTimeMillis()
calendar.set(Calendar.HOUR_OF_DAY, hour)
calendar.set(Calendar.MINUTE, minute)
//if alarm time has already passed, increment day by 1
if (calendar.timeInMillis <= System.currentTimeMillis()) {
calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1)
}
val alarmInfo = AlarmClockInfo(calendar.timeInMillis, alarmPendingIntent)
}
As mentioned above this problem is specific to android 13. If there is something more specific I should post here please let me know in a comment and I can update.
android adding DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION in release build
Did you look at how how Android 13 changed some of the permissions / manifest settings for this to work?