Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
121 views
in Technique[技术] by (71.8m points)

java - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...