Getting Detail/Expanded Text from an Android Notification?

后端 未结 4 1130
北荒
北荒 2021-01-06 07:55

I\'ve implemented a notification listener to look out for a Gmail notification.

I want to collect the expanded text (bigtext) from the notification as shown in the n

4条回答
  •  天涯浪人
    2021-01-06 08:13

    Finally, I am able to solve this issue by using this code.

    ArrayList groupedNotifications = new ArrayList<>();
    
    for(StatusBarNotification statusBarNotification : mNotificationManager.getActiveNotifications()) {
        if(statusBarNotification.getNotification().getGroup().equals(NOTIFICATION_GROUP)) {
              groupedNotifications.add(statusBarNotification);
        }
    }
    
    CharSequence stackNotificationMultiLineText[] = groupedNotifications.get(ZEROTH_INDEX).getNotification().extras.getCharSequenceArray(NotificationCompat.EXTRA_TEXT_LINES);
    

    If you try to use getCharSequence("android.textLines"), it returns you null because NotificationCompat.EXTRA_TEXT_LINES returns you the array of CharSequence and not a single CharSequence object.

提交回复
热议问题