Mukesh Gupta Mukesh Gupta - 1 month ago 9
Android Question

How to Call a java class after 10 minutes of non-interacting with notification bar?

I am creating a notification at particular time using alarm Manager and notification manager, i gave user three action in notification bar "Snooze", "Cancel", "Take". Here is the situation i want to resend the notification after 10 min of this notification again and again till the user presses these above buttons.
Can any body help and provide a decent logic to do this.

Answer

I would schedule a repeating Alarm and only cancel it on a non "Snooze" action. See the setRepeating method of AlarmManager

https://developer.android.com/reference/android/app/AlarmManager.html#setRepeating(int,%20long,%20long,%20android.app.PendingIntent)

to schedule a new alarm after the initial one goes off, you'll want to start a service with the AlarmManager which can then handle the Snooze action for you.

Using Alarmmanager to start a service at specific time