开发者

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开发者_Go百科 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.


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()


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜