简体   繁体   English

接收通知文本信息

[英]Receive Notification text info

If I get notification from twitter then I want to get all the text from it.如果我收到来自 twitter 的通知,那么我想从中获取所有文本。 if it's tweeted by user "ABCD" (@abcd) and the tweet contains "Hello" so "do this stuff".如果它是由用户“ABCD”(@abcd)发布的,并且推文包含“你好”,那么“做这件事”。

So how can i get to that?那么我怎样才能做到这一点? Is there any notification receiver like broadcast receiver?有没有像广播接收器这样的通知接收器?

You can use the NotificationListenerService to receive the notifications.您可以使用 NotificationListenerService 来接收通知。 Then, depending on your app's requirements, parse the contents of the notification and perform your desired action.然后,根据您的应用程序的要求,解析通知的内容并执行您想要的操作。

Here is the documentation for NotificationListenerService. 这是NotificationListenerService 的文档 It looks fairly straight forward to set up.设置起来看起来相当简单。 You'll need to add a node to your AndroidManifest.xml and then create a class that extends NotificationListenerService.您需要向 AndroidManifest.xml 添加一个节点,然后创建一个扩展 NotificationListenerService 的类。

Here is an example on Github of someone using the NotificationListenerService. 这是 Github 上某人使用 NotificationListenerService 的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM