如何从通知中读取内容意图

How to read the content intent from the notification

我正在使用 NotificationListenerService 阅读状态栏上发布的通知。我能够阅读通知上的标题和文本,但无法找到一种方法来阅读为通知设置的操作和内容意​​图。

https://developer.android.com/reference/android/service/notification/NotificationListenerService.html

在您的 onNotificationPosted(), you have access to the StatusBarNotification. With that, you can call getNotification() and then use the public member variables contentIntent and actions 中分别访问内容意图和操作。

@Override
public void onNotificationPosted(StatusBarNotification sbn) {
  Notificiation notification = sbn.getNotification();

  PendingIntent contentIntent = notification.contentIntent;
  Actions[] actions = notification.actions;
}