androidnotificationsandroid-4.3-jelly-bean

Android 4.3.X Notification Listener


I am trying to create an App that uses the new Android service to read all notifications and also remove them, but it is not working. In the Manifest I have:

<service android:name="com.tortuga.shutapp.NotificationListener"
     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>

I have a class NotificationListener that extends NotificationListenerService I override the two methods onNotificationPosted(StatusBarNotification sbn), onNotificationRemoved(StatusBarNotification sbn).

I have given it permission under Security->Notification Access... But I still can't read any notification that pops. What seems to be the problem?

Thanks!


Solution

  • Android caches the binder returned from onBind so if your actions are very similar and your app binds first, then your binder will be returned to the system one instead of the system binder (returned from super.onBind(intent)

    Luckily, Android keys the binder cache based on the intent action. I would give your intent some dummy action so that it doesn't get mixed with the system one. I've solved the same problem by doing this. NOTE: categories are not sufficient.