thasneemp / NotificationListener

Notification Listener it will listen all the app notification
0 stars 0 forks source link

does not work with whatsapp android 6.0.1 #1

Open kanhaiyabgs opened 7 years ago

kanhaiyabgs commented 7 years ago

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

thasneemp commented 7 years ago

Have you enabled Notification Access in settings for this app?

kanhaiyabgs commented 7 years ago

yes I did
did you tried it on whatsapp it does not mention whatsapp package name even if whatsappp notification is present

thasneemp commented 7 years ago
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 capture When running the app log will be like this

kanhaiyabgs commented 7 years ago

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)