Skip to content

Instantly share code, notes, and snippets.

@garg-lucifer
Last active September 24, 2022 08:56
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 garg-lucifer/36622ce8db0574c6fa24ccd738d2462c to your computer and use it in GitHub Desktop.
Save garg-lucifer/36622ce8db0574c6fa24ccd738d2462c to your computer and use it in GitHub Desktop.
private fun removeAlarm(taskInfo: TaskInfo){
val alarmManager = activity?.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val intent = Intent(requireContext(), AlarmReceiver::class.java)
// It is not necessary to add putExtra
intent.putExtra("task_info", taskInfo)
val pendingIntent = PendingIntent.getBroadcast(requireContext(), taskInfo.id, intent, PendingIntent.FLAG_IMMUTABLE)
alarmManager.cancel(pendingIntent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment