Monitoring notification from other applications

I'm working on an Android app that can listen to notifications from other apps like gmail and accumulate them in one place, or create my own custom notifications based on notifications generated by other apps. A similar application will be notified about the metro. Below is the link to this app:

https://play.google.com/store/apps/details?id=com.nlucas.wp7notifications&hl=en

This app is able to block notifications from other apps and create your own notifications. I would like to know how this is possible. How an app can track notifications from other apps. I googled the same thing, but I couldn't find any solution.

+3


source to share


1 answer


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 the 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>

      

+1


source







All Articles