I am trying to read notifications using the Android 4.3 Notification Listener API. I followed several tutorials for example. http://gmariotti.blogspot.hk/2013/11/notificationlistenerservice-and-kitkat.html?view=magazine
Also this question does not solve my problem as I do not want to read Big View notifications. I can do it
Getting verbose / extended text from Android notifications?
This is my code:
Log.d(logtag,"CharSequence - Title: "+sbn.getNotification().extras.getCharSequence("android.title")+
" CharSequence - textLines: "+sbn.getNotification().extras.getCharSequence("android.textLines")+
" CharSequence - subText: "+sbn.getNotification().extras.getCharSequence("android.subText")+
" CharSequence - text: "+sbn.getNotification().extras.getCharSequence("android.text")+
" CharSequence - infoText: "+sbn.getNotification().extras.getCharSequence("android.infoText")+
" CharSequence - summaryText: "+sbn.getNotification().extras.getCharSequence("android.summaryText"));
Log.d(logtag,"String - Title: "+sbn.getNotification().extras.getString("android.title")+
" String - textLines: "+sbn.getNotification().extras.getString("android.textLines")+
" String - subText: "+sbn.getNotification().extras.getString("android.subText")+
" String - text: "+sbn.getNotification().extras.getString("android.text")+
" String - infoText: "+sbn.getNotification().extras.getString("android.infoText")+
" String - summaryText: "+sbn.getNotification().extras.getString("android.summaryText"));
Log.d(logtag, "--------------------------------------------------------------------------------------------");
Notification mNotification=sbn.getNotification();
if (mNotification!=null){
Bundle extras = mNotification.extras;
String notificationTitle =
extras.getString(Notification.EXTRA_TITLE);
Bitmap notificationLargeIcon =
((Bitmap) extras.getParcelable(Notification.EXTRA_LARGE_ICON));
CharSequence notificationText =
extras.getCharSequence(Notification.EXTRA_TEXT);
CharSequence notificationSubText =
extras.getCharSequence(Notification.EXTRA_SUB_TEXT);
CharSequence notificationTextLines =
extras.getCharSequence("android.textLines");
Log.d(logtag, "New Title: "+notificationTitle);
Log.d(logtag, "New Text: "+notificationText);
Log.d(logtag, "New subText: "+notificationSubText);
Log.d(logtag, "New textLines: "+notificationTextLines);
Log.d(logtag, "--------------------------------------------------------------------------------------------");
And this is my ADB screen output:
D/AANN - NotificationListener﹕ CharSequence - Title: Alex CharSequence - textLines: null CharSequence - subText: null CharSequence - text: null CharSequence - infoText: null CharSequence - summaryText: 8 new messages.
D/AANN - NotificationListener﹕ String - Title: Alex String - textLines: null String - subText: null String - text: null String - infoText: null String - summaryText: 8 new messages.
D/AANN - NotificationListener﹕ New Title: WhatsApp
D/AANN - NotificationListener﹕ New Text: null
D/AANN - NotificationListener﹕ New subText: null
D/AANN - NotificationListener﹕ New textLines: null
What I'm trying to do is get each of these notifications either as an object string or whatever. All I need is a text, header and source application from each of these notifications.
, , , Null,
http://i.stack.imgur.com/t09Ns.png