Reputation: 319
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 ?
Upvotes: 4
Views: 14005
Reputation: 72341
You can use from API 18 NotificationListenerService
to get notified about StatusBarNotifications
.
Upvotes: 8
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