I am creating a simple Android application in which a notification is created.
Now I want to delete the notification if the user is not responsible for a certain time
This means that I want to delete the notification in five minutes
You need a combination of Alarmmanager and alerts.
Register an alarm manager that will call the service in 5 minutes and use the NotificationManager.cancel function in the service implementation.
An example of an alarm service is here . I suppose you know that you are using Notification Manager .
AlarmManager , . Java Runnable Handler .
Handler h = new Handler(); long delayInMilliseconds = 5000; h.postDelayed(new Runnable() { public void run() { mNotificationManager.cancel(id); } }, delayInMilliseconds);
:
TimerTask-Class.