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 ?
Asked
Active
Viewed 1.3k times
4
-
Do you want to read an email and do something with it? You do not need the status bar for that – ACC Mar 19 '12 at 22:47
-
Yes, i need to be notified when i receive a new gmail and then read a gmail from code. But in my research on this i find out that it is impossible. – djcharon Mar 19 '12 at 22:51
2 Answers
8
You can use from API 18 NotificationListenerService
to get notified about StatusBarNotifications
.

Ovidiu Latcu
- 71,607
- 15
- 76
- 84
6
... 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.