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/60c642067c3ccb7aa01ff87af3fd26e8 to your computer and use it in GitHub Desktop.
Save droid-lover/60c642067c3ccb7aa01ff87af3fd26e8 to your computer and use it in GitHub Desktop.
a normal sample of using alarm manager in android11 with pendingIntent.
val intent = Intent(this, AlarmReceiver::class.java)
val pendingIntent = PendingIntent.getBroadcast(
this,
ALARM_SERVICE_CODE,
intent,
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