Created
February 3, 2022 13:18
-
-
Save droid-lover/aebe7f3d425efcd853e1ef2aefe51e6b to your computer and use it in GitHub Desktop.
a normal sample of using alarm manager in android12 with pendingIntent changes by using its mutability.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val intent = Intent(this, AlarmReceiver::class.java) | |
val pendingIntent = PendingIntent.getBroadcast( | |
this, | |
ALARM_SERVICE_CODE, | |
intent, | |
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT | |
) | |
val mAlarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager | |
mAlarmManager.setExactAndAllowWhileIdle( | |
AlarmManager.RTC, | |
calendar.timeInMillis, | |
pendingIntent | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment