简体   繁体   中英

android react to new notifications

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 ie 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.

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.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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