Android 接收通知打开和取消事件 [英] Android receive notification open and cancel event

查看:68
本文介绍了Android 接收通知打开和取消事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从我的 webService 接收数据以生成自定义通知.

I receive data from my webService to generate custom notifications.

我想跟踪意图以了解通知上的打开(点击)或取消(滑动)事件,以报告服务器用于分析.

I want to track Intent to be aware of open (click) or cancel (swipe) event on a notification , to report server for analytics.

onIntentStartonIntentCanceled 是否有任何监听器?

Is there any listener for onIntentStart or onIntentCanceled ?

也许是 notificationId 通知的监听器?

Maybe a listener for notifications by notificationId ?

我想在不更改用户的 contentIntent 或 DeleteIntent 或要求用户将代码行添加到 NotificationHandlerActivity 的情况下执行此操作!

i want to do this without changing user's contentIntent or DeleteIntent or asking user to add lines of code to NotificationHandlerActivity !

推荐答案

您可以设置 contentIntentdeleteIntent 使用 setContentIntent/setDeleteIntent.要了解更多信息,请访问:构建通知.

You can set contentIntent and deleteIntent using setContentIntent/setDeleteIntent. To find more please visit: Building a Notification.

此外,您可以将 NotificationListenerService 子类化,这是一项服务当发布或删除新通知,或者它们的排名发生变化时,它会收到来自系统的调用.

In addition you can subclass NotificationListenerService which is a service that receives calls from the system when new notifications are posted or removed, or their ranking changed.

这里您可以找到如何使用它的示例.

Here you can find example how to use it.

这篇关于Android 接收通知打开和取消事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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