Android - DeleteIntent, how to use?

百般思念 提交于 2019-12-20 05:01:20

问题


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?


回答1:


Create a broadcast or service PendingIntent, pointing to a BroadcastReceiver or IntentService that will reset your counter, and associate that PendingIntent with your Notification via deleteIntent.



来源:https://stackoverflow.com/questions/6370583/android-deleteintent-how-to-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!