How to read body notification of Gmail?

29 Views Asked by At

How to read body Gmail on logcat? In logcat just reading the subject, but the body Gmail not written on logcat. I'm using Java in Android Studio, with an Android 7 device.

The code:

@Override
public void onNotificationPosted(StatusBarNotification sbn) {
    // Notifikasi baru diterima
    String title = sbn.getNotification().extras.getString("android.title");
    String text = sbn.getNotification().extras.getString("android.text");
    CharSequence bigText = (CharSequence)sbn.getNotification().extras.getCharSequence(Notification.EXTRA_TEXT);
    if(bigText != null){
        String body = bigText.toString();
        Log.i("NotificationListener", "Notification Package: " + sbn.getPackageName());
        Log.i("NotificationListener","Notification Body: " +  body);
        Log.i("NotificationListener", "Notification Title: " + title);
    }
}

enter image description here enter image description here in the logcat just write the subject email

I want the logcat to write the body Gmail and subject, but in logcat only the subject is written.

0

There are 0 best solutions below