How to get notified when notified

I want to read / access / register notifications shot in the notification panel by other applications.

I searched Intents and PendingIntents many times, but could not get a solution.

Should my application need to be notified when any notification starts?

Or does the Android system support reading user-level notifications?

+8
android android-intent notifications android-pendingintent accessibilityservice
source share
4 answers

Finally got an answer. !!! Using AccessibilityService

 public class NotificationService extends AccessibilityService { @Override public void onAccessibilityEvent(AccessibilityEvent event) { // TODO Auto-generated method stub. //Code when the event is caught } @Override public void onInterrupt() { // TODO Auto-generated method stub. } @Override protected void onServiceConnected() { AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.feedbackType = 1; info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.notificationTimeout = 100; setServiceInfo(info); } } 

And my manifest:

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.test.notify" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <service android:name=".NotificationService" android:enabled="true"> <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="android.accessibilityservice.AccessibilityService"/> </intent-filter> </service> </application> </manifest> 

Enjoy the coding. !!! :)

+5
source share

Starting with api 18 (android 4.3), it is possible: http://developer.android.com/reference/android/service/notification/NotificationListenerService.html

Very easy to use, but the user must give permission to the application manually.

+7
source share

There is no API to access any notification. At least it will be a security hole. Only you can catch some events that trigger notifications (e.g. SMS).

0
source share

A Notification raised by sending an Intent .

 Intent intent = new Intent(this, NotificationReceiver.class); 

NotificationReceiver catches Intent and pulls a Notification .

In one of your applications, you can catch the same Intent using BroadCastReceiver and filter on the Intent you want.

0
source share

All Articles