Does anyone know how we can add text, to the right of the app's name in a notification and before the timestamp(when)?
ChannelId is a unique String to identify each NotificationChannel and is used in Notification. Builder (line 7) when constructing the Notification object. NotificationChannel settings, except channel name and description text, are immutable after it is submitted to NotificationManager at line 5.
Android proposes several types of notifications to inform the user: notifications in the system bar. sound notifications.
setContentTitle(): It is used to set the title of notification. setContentText(): It is used to set the text message.
To use NotificationListenerService, we need to create a java file which extends NotificationListenerService and implement two callback methods. Both methods have a parameter named “sbn”, which is an object of StatusBarNotification class. StatusBarNotification provides necessary information about Notifications.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With