Ok, THIS ISN'T WELL TESTED. I just wanted to throw it up there in hopes of helping others with the same issue. It seems that you have to use onListenerConnected and getActiveNotification() to make OREO devices receive notifications. Here is my code:
public class ListenForNotificationsService extends NotificationListenerService {
private String TAG = this.getClass().getSimpleName();
@Override
@TargetApi(Build.VERSION_CODES.N)
public void onListenerConnected() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
getActiveNotifications();
}
Log.d(TAG, "Listener connected");
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.d(TAG, "Notification received");
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
if (sbn.getPackageName() != null) {
Log.d(TAG, "Notification removed:" + sbn.getPackageName() + ":" + sbn.getId());
}
}
@Override
@TargetApi(Build.VERSION_CODES.N)
public void onListenerDisconnected() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// Notification listener disconnected - requesting rebind
requestRebind(new ComponentName(this, NotificationListenerService.class));
}
}
}
Please note, I don't know if the onListenerDisconnected() is correct or even necessary so use with caution. Another thought as well is that because of the DEEP SLEEP changes in OREO there may be other things needed to handle that. YMMV, It was just that this wasted a lot of my time so hopefully it will help someone else.