Below is my code for capturing notifications. I do not understand why onNotificationPosted is not being fired.
I provide access to My Application Notifications from Settings> Security, and the onCreate from MyNotifService also starts, but onNotificationPosted does not start.
What am I missing or doing wrong?
From my MainActivity onCreate () function:
Intent intent = new Intent(this, MyNotifService.class); this.startService(intent);
My Service Code that extends NotificationListenerService :
@SuppressLint("NewApi") public class MyNotifService extends NotificationListenerService { @Override public void onNotificationPosted(StatusBarNotification sbn) { super.onNotificationPosted(sbn); Log.v("focus", "in onNotificationPosted() of MyNotifService"); } @Override public void onCreate() { super.onCreate(); Log.v("focus", "in onCreate() of MyNotifService"); } }
In the manifest file, I have this:
<service android:name="com.mavdev.focusoutfacebook.notifications.MyNotifService" 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>
source share