Home » Android » Android notification: add text after app's name, before when

Android notification: add text after app's name, before when

Posted by: admin June 15, 2020 Leave a comment

Questions:

Does anyone know how we can add text, to the right of the app’s name in a notification and before the timestamp(when)? preview

How to&Answers:

in Notification.Builder there is a method called setSubText().

You can pass the message to display as String.

Link to documentation : https://developer.android.com/reference/android/app/Notification.Builder.html#setSubText(java.lang.CharSequence)

Notification noti = new Notification.Builder(mContext)
     .setContentTitle(AppName)
     .setContentText(message)
     .setSmallIcon(R.drawable.logo)
     .setSubText(senders_mail)
     .build();