Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: get all the notifications by code

I am using some home replacement that allow me to hide the notification Bar and that's something I really like.

All the informations can be replaced by some widgets, but I would like to display the notifications too.

As I already developed some applications, I would like to know if there is a command line that allow an application to get all the notifications. I plan to add this to a widget or a toast.

Thank a lot for any clue or help.

like image 893
Waza_Be Avatar asked Jun 13 '10 00:06

Waza_Be


People also ask

How do I get multiple push notifications on Android?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.

How do I use NotificationListenerService?

You need to grant access to your app to read notifications: "Settings > Security > Notification access" and check your app. Show activity on this post. Inside the NotificationListenerService you need a looper to communicate with GUI thread so you can create a broadcast to handle the GUI interaction.


2 Answers

Since Android API Level 18 (Android 4.3) there is a class NotificationListenerService. You must set the Permission BIND_NOTIFICATION_LISTENER_SERVICE and use a intent-filter with the action NotificationListenerService.

 <service android:name=".NotificationListener"
          android:label="@string/service_name"
          android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
     <intent-filter>
         <action android:name="android.service.notification.NotificationListenerService" />
     </intent-filter>
 </service>

Source: http://developer.android.com/reference/android/service/notification/NotificationListenerService.html#getActiveNotifications()

like image 174
esters Avatar answered Sep 29 '22 04:09

esters


I will answer my question because I found something on an other forum.

Seem that you can access them declaring your application as an (sorry for the french term, I couldn't find an english translation) "gestionnaire d'accessibilité" that you may translate as "accessibility manager"

More information here: https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html

That may be dangerous and has a lot of negative point, but an other dev that is also working on a custom Home assure me that this feature work and he was able to create his own notification bar.

like image 36
Waza_Be Avatar answered Sep 29 '22 05:09

Waza_Be