Android的应对新的通知 [英] android react to new notifications

查看:95
本文介绍了Android的应对新的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能向不来自我自己的程序的通知反应呢?我需要一些种类的接收器时,即K9创建一个通知或WhatsApp的或任何的反应。我不一定需要读取通知的内容。到目前为止,我已经遇到什么对我的搜索,也许你可以提供帮助。如果我需要root的解决方案,我会接受,如果必要的。

is it possible to react to a notification that did not come from my own program? I need some kind of receiver that reacts when i.e. k9 creates a notification or whatsapp or whatever. I don't necessarily need to read the contents of the notification. So far I've come across nothing on my search, maybe you can help. If I need root for the solution, I'd accept that if necessary.

谢谢,
Catscrash

thanks, Catscrash

推荐答案

我知道这已经坐了一点点,但我在搜索碰到它,我想我会分享我发现了什么。

I know this has been sitting for a little bit, but I came across it in my searching, and I figured I would share what I found.

有一种方法可以做到这一点,并且不需要生根/改装。我不知道你的目标是什么API级别,但你应该看看无障碍。它着眼于帮助那些残疾人,但随着用户的权限,它授予其他应用访问的东西,如通知。您可以通过源码包过滤,得到的内容,和这么多。

There is a way to do this, and rooting/modding is not required. I do not know what API level you are targeting, but you should look into Accessibility. It is geared towards assisting those with disabilities, but with the user's permission, it grants other apps access to things such as notifications. You can filter by the source package, get the contents, and so much more.

下面是对无障碍服务页面的链接:的http:/ /developer.android.com/guide/topics/ui/accessibility/services.html

Here is a link to a page on Accessibility Services: http://developer.android.com/guide/topics/ui/accessibility/services.html

这是我用来运行一个快速测试来证明自己,它的工作。做一个快速的项目,这一点,创建了一些通知,并观察LogCat中。这个记录比刚刚从状态栏通知得多,因为你会看到: https://开头依据。 github.com/qihnus/1909616

This is what I used to run a quick test to prove to myself that it did work. Make a quick project with this, create some notifications, and watch LogCat. This logs much more than just the notifications from the status bar, as you'll see: https://gist.github.com/qihnus/1909616

这篇关于Android的应对新的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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