61.8 Adding Actions to a Notification
Another way to add interactivity to a notification is to create actions. These appear as buttons beneath the notification message and are programmed to trigger specific intents when tapped by the user. The following code, if added to the sendNotification() method, will add an action button labeled “Open” which launches the referenced pending intent when selected:
final Icon icon = Icon.createWithResource(MainActivity.this,
android.R.drawable.ic_dialog_info);
Notification.Action action =
new Notification.Action.Builder(icon, "Open", pendingIntent)
.build();
Notification notification = new Notification.Builder(MainActivity.this, CHANNEL_ID)
...