Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save droid-lover/aebe7f3d425efcd853e1ef2aefe51e6b to your computer and use it in GitHub Desktop.
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.
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