Android-DeleteIntent,如何使用?
目前,我的 Android 应用程序中有一个通知,该通知具有 PendingIntent,因此单击它时会打开一个活动。
我目前保留了一个通知计数器,类似于本机未接来电通知。
单击通知时,我可以将此计数器重置为 0。
当用户选择“清除所有通知”按钮时,我还想将计数器重置为 0。我进行了搜索,发现执行此操作的方法是使用DeleteIntent。
但我不知道如何将其与我的 PendingIntent 一起使用,有人可以帮助我吗?
I currently have a notification in my Android application that has a PendingIntent so that when it is clicked an activity is opened.
I currently keep a counter for the notification, similar to the native missed calls notification.
I can reset this counter to 0 when the notification is clicked.
I also want to reset the counter to 0 when the user selects the "Clear all notifications" button. I have done a search and seen the way to do this is to use the DeleteIntent.
But I cant figure out how to use this alongside my PendingIntent, can anyone help me out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建广播或服务
PendingIntent
,指向将重置计数器的BroadcastReceiver
或IntentService
,并关联该PendingIntent
> 通过deleteIntent
使用您的通知
。Create a broadcast or service
PendingIntent
, pointing to aBroadcastReceiver
orIntentService
that will reset your counter, and associate thatPendingIntent
with yourNotification
viadeleteIntent
.