In order to read android notifications we need to create a custom class that extends NotificationListenerService
class. But I am not able to understand what the inside this method does?
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.i(TAG,"********** onNotificationPosted");
Log.i(TAG,"ID :" + sbn.getId() + "t" + sbn.getNotification().tickerText + "t" + sbn.getPackageName());
Intent i = new Intent("com.example.readandroidnotification.NOTIFICATION_LISTENER_EXAMPLE");
i.putExtra("notification_event","onNotificationPosted :" + sbn.getPackageName() + "n");
sendBroadcast(i);
}
Can anyone explain the working of this code?
I recommend reading some documentation about Android: