如何在android中的特定时间之后删除通知? [英] How to remove the notification after the particular time in android?

查看:19
本文介绍了如何在android中的特定时间之后删除通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的 android 应用程序,其中创建了一个通知.

现在我想删除通知,如果用户在特定时间后没有响应

这意味着我想在五分钟后删除通知

解决方案

您需要的是 Alarmmanager 和 notificationmanger 的组合.

注册将在 5 分钟内调用服务的警报管理器,并在服务实现中使用 NotificationManager.cancel.

报警服务示例是 这里.我想您知道使用 通知管理器.>

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

解决方案

What you need is a combination of Alarmmanager and notificationmanger.

Register the alarm manager that will call a service in 5 minutes and use NotificationManager.cancel in the service implementation.

Alarm Service Sample is here. I suppose you know to use Notification Manager.

这篇关于如何在android中的特定时间之后删除通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆