Daniele B
Daniele B

Reputation: 20412

Android Notifications: how to include extra text in top line

These are 2 notifications on Android 7+:




Can anyone explain how to include the extra text between the app name and the notification time, as shown in the Gmail notification?

Is there a method of NotificationCompat.Builder to set that text?

   NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NotificationChannels.TRIPS_CHANNEL_ID)
      .setSmallIcon(ICON_DRAWABLE)
      .setColor(TITLE_COLOR)
      .setContentTitle(FIRST_LINE_TEXT) // "Remote input"
      .setContentText(SECOND_LINE_TEXT); // "Try typing some text!"

Upvotes: 5

Views: 1641

Answers (1)

Daniele B
Daniele B

Reputation: 20412

Found the answer!

It's the subtext:

.setSubText("text to show next to app name")

Upvotes: 8

Related Questions