Open kanhaiyabgs opened 7 years ago
Have you enabled Notification Access in settings for this app?
yes I did
did you tried it on whatsapp
it does not mention whatsapp package name even if whatsappp notification is present
public void onNotificationPosted(StatusBarNotification sbn) {
String tickerText= sbn.getNotification().tickerText.toString();
if (sbn.getPackageName().equalsIgnoreCase("com.whatsapp")) {
Log.d("NOTIFICATION_LISTENER", "onNotificationPosted: Whatsapp : " + tickerText);
} else {
Log.d("NOTIFICATION_LISTENER", "onNotificationPosted : " + sbn.getPackageName());
}
super.onNotificationPosted(sbn);
}
if you need to get whatsapp notification you must write the conditions like this
When running the app log will be like this
does
not work
below is my log cat
[ 06-13 16:11:10.727 10319-10332/com.example.pavilion.notificationone W/NotificationListenerService[NListenerService]: Error running onNotificationPosted java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference at com.example.pavilion.notificationone.NListenerService.onNotificationPosted(NListenerService.java:14) at android.service.notification.NotificationListenerService.onNotificationPosted(NotificationListenerService.java:179) at android.service.notification.NotificationListenerService$INotificationListenerWrapper.onNotificationPosted(NotificationListenerService.java:707) at android.service.notification.INotificationListener$Stub.onTransact(INotificationListener.java:71) at android.os.Binder.execTransact(Binder.java:453)](url)
It is not working in android 6.0.1 It is not able to work with whatsapp It does not even mention package name of whatsapp