0

Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?

It need this to start an activity if something happend in the status bar. I don't mean the "Status bar windows".

Maybe I can use an IntentFilter like :

IntentFilter statusBarIntentFilter = new IntentFilter(android.bla.bla.ACTION_STATUSBAR_STATE_CHANGED);

Thank you so far in advanced!

BR

Nathan Koop
  • 24,803
  • 25
  • 90
  • 125
Regina Balusz
  • 91
  • 2
  • 11

2 Answers2

0

Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?

No, sorry. You cannot spy on other applications' notifications from the Android SDK.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Hi, thanks for your fast response! Its not my intention to spy the notification content of another app. I just want to know, if a new symbol or whatever was added to the status bar. Afterwards I would like to start various activities. I could use the AccessibilityService (AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED), but this needs relatively deep/dangerous permission authorizations! – Regina Balusz Apr 23 '12 at 18:05
  • 1
    @ReginaBalusz: IMHO, you should not "start various activities" just because a notification is displayed. The primary point behind notifications is to **NOT** interrupt the user when something happens of note in the background. Yes, you can use accessibility APIs to detect notifications, but the point behind those APIs is to provide accessibility capabilities without disturbing the existing application flow. Popping up an activity out of the blue would count as "disturbing the existing application flow". – CommonsWare Apr 23 '12 at 18:18
  • You're fully right regarding "don't disturb the flow of other apps"! The problem is that Im currently writing an app, which shall listen to any Calender event that occurs. Unfortunately there is no IntentFilter, which could be used to listen to "Reminder-Events" fired by the Calendar. This IntentFilter could be used in a BroadcastReceiver. The only way I determined is, that the Calendar app adds a Notification to the Status bar in case of a Reminder. So I was thinking to find out a way, to be informed, that a new notification was added to the STatus bar. Ive to look for an alt. – Regina Balusz Apr 23 '12 at 18:46
  • You can try use a content observer. Pre ice cream sandwich you can use "content://com.android.calendar/" and monitor for changes. calendar_alerts I think store what you'd want. Then you can monitor for when notifications are raised and as the data changes in the content provider you should be able to pick up on that. It's not documented and is accessing data that could change in the future. Saying that it has changed in ICS as there's now an API for accessing the calendar information so I would guess with a combination of both you can achieve what you want. – Andrew May 17 '12 at 10:02
  • Thanks for your response Andrew. I will try it! – Regina Balusz Nov 16 '12 at 07:16
0

Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?

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.

Community
  • 1
  • 1
TomJ
  • 5,389
  • 4
  • 26
  • 31