I'm having trouble creating a service which extends android.service.notification.NotificationListenerService
As per https://developer.android.com/reference/android/service/notification/NotificationListenerService.html I have added the following to the manifest:
<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>
I override Service#onStartCommand:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "Got onStartCommand");
return super.onStartCommand(intent, flags, startId);
}
and NotificationListenerService#onListenerConnected:
@Override
public void onListenerConnected() {
Log.d(TAG, "Got onListenerConnected");
}
When I run, though, starting the service with an explicit intent, I see that onStartCommand runs but not onListenerConnected. If I try and run requestInterruptionFilter(NotificationListenerService.INTERRUPTION_FILTER_NONE), from onStartCommand (which is what I want to do) I get W/NotificationListenerService[NotificationListener]: Notification listener service not yet bound.
Any idea why I'm not getting onListenerConnected () (and thus can't send requestInterruptionFilter)?
This is on Lollipop 5.1.1 on Xperia Z1 compact.

Android 5.1 Notification access screenshot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With