如何在Android上的特定时间后删除通知? [英] How to remove the notification after the particular time in android?
问题描述
我创建一个简单的Android应用程序中创建一个通知。
I am creating an simple android application in that created a notification.
现在我想删除通知,如果用户没有在特定的时间后,响应
Now i want to remove the notification if the user doesn't response after the particular time
这意味着我想经过五分钟删除通知
That means i want remove the notification after five mins
推荐答案
您需要的是Alarmmanager和notificationmanger的组合。
What you need is a combination of Alarmmanager and notificationmanger.
注册报警管理器,将在5分钟内调用服务,并在服务实现使用NotificationManager.cancel。
Register the alarm manager that will call a service in 5 minutes and use NotificationManager.cancel in the service implementation.
报警服务示例是<一个href=\"http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlarmService.html\"相对=nofollow>此处。我想你知道使用通知管理器。
Alarm Service Sample is here. I suppose you know to use Notification Manager.
这篇关于如何在Android上的特定时间后删除通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!