Reputation: 31
I am working on an android app that can listen to notifications from other apps like gmail and accumulate them at one location or generate custom notifications of its own based on the notifications generated by other apps. A similar app would be metro notification. The following is a link to this app:
https://play.google.com/store/apps/details?id=com.nlucas.wp7notifications&hl=en
This app is able to block notifications of other apps and generate custom notifications of its own. I would like to know how this is possible. How an app is able to monitor the notifications from other apps. I googled the same yet i was unable to find any solution.
Upvotes: 3
Views: 1368
Reputation: 167
You can extend NotificationListenerService and override onNotificationPosted method
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.i(TAG, "onNotificationPosted");
Log.i(TAG, "ID :" + sbn.getId() + "\t" + sbn.getNotification().tickerText + "\t" + sbn.getPackageName());
}
You also need to declare your service in manifest
<service android:name="yourpackage.yourservice"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
Upvotes: 1