djcharon
djcharon

Reputation: 319

Android How can i intercept the Status Bar Notifications?

i would want to know if i can intercept a notification from Status Bar. The purpose of this is to somehow intercept an incoming a gmail and do something with it, i don't really need the content of the email, but it would be nicer. But since gmail had stopped the access to receiver and db, i am trying to find a workaround solution by listen the Status Bar if even this is possible. Any ideas ?

http://groups.google.com/a/googleproductforums.com/forum/#!category-topic/gmail/reading-and-receiving-messages/XD0C4sw9K7U

Upvotes: 4

Views: 14005

Answers (2)

Ovidiu Latcu
Ovidiu Latcu

Reputation: 72341

You can use from API 18 NotificationListenerService to get notified about StatusBarNotifications.

Upvotes: 8

TomJ
TomJ

Reputation: 5479

... i am trying to find a workaround solution by listen the Status Bar if even this is possible. Any ideas ?

You can listen for status bar notifications by using AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED.

Here is a StackOverflow answer on this subject, and here is a working example I put together based upon that answer. I actually put that example together because an application was, essentially, spamming my wife's notification bar with advertisements and there was no clear way of telling who the offending application was.

Upvotes: 6

Related Questions