Question

My Android app notifications are relevant only for a short time period. So if the user did not interact with the notification for a X minutes I would like to remove the notification. Is there an "out of the box" way to do it?
In case there is no easy way to do it, here is my current plan:
Keep the notification id plus the TTL and have a "cleanup" thread that will wakeup from time to time and will remove aged notifications.
Any better ideas?

Thanks

Was it helpful?

Solution 2

I don't think is the another way to do with handler because as per my thinking it is the same way as your first idea because in handler the procedure is same means in this one message is handle after some X minute so in this message u have to pass your ttl and notification id and as the handler pass the message after x minute to the service and in service u have to do NotificationManager.cance and that remove the notification

OTHER TIPS

Here You have to use Combination of Alarmmanager and notificationmanger.

Register Alarm manager that will call service in some X time and use Notification

Manager.cancel in service implementation

For example of alarm service, follow this link:

http://www.javacodegeeks.com/2012/09/android-alarmmanager-tutorial.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top