Source:
private void modifyForTextOnly(final Builder builder, final ArrayList<Message> messages) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { NotificationCompat.MessagingStyle messagingStyle = new NotificationCompat.MessagingStyle(mXmppConnectionService.getString(R.string.me)); Conversation conversation = messages.get(0).getConversation(); if (conversation.getMode() == Conversation.MODE_MULTI) { messagingStyle.setConversationTitle(conversation.getName()); } for (Message message : messages) { String sender = message.getStatus() == Message.STATUS_RECEIVED ? UIHelper.getMessageDisplayName(message) : null; messagingStyle.addMessage(UIHelper.getMessagePreview(mXmppConnectionService,message).first, message.getTimeSent(), sender); } builder.setStyle(messagingStyle); } else { if(messages.get(0).getConversation().getMode() == Conversation.MODE_SINGLE) { Log.d("NotificationService", messages.get(0).getContact().getDisplayName()); builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages))); builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get((messages.size() - 1))).first); } else { final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); for (Message message : messages) { final String name = message.getContact().getDisplayName(); style.addLine(Html.fromHtml("<b>"+name+"</b>: "+message.getBody())); } builder.setStyle(style); if(messages.size() == 1) { builder.setContentText(messages.get(0).getBody()); } else { builder.setContentText(messages.size() + " unread messages"); } } } }

Target:
private void modifyForTextOnly(final Builder builder, final ArrayList<Message> messages) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { NotificationCompat.MessagingStyle messagingStyle = new NotificationCompat.MessagingStyle(mXmppConnectionService.getString(R.string.me)); Conversation conversation = messages.get(0).getConversation(); if (conversation.getMode() == Conversation.MODE_MULTI) { messagingStyle.setConversationTitle(conversation.getName()); } for (Message message : messages) { String sender = message.getStatus() == Message.STATUS_RECEIVED ? UIHelper.getMessageDisplayName(message) : null; messagingStyle.addMessage(UIHelper.getMessagePreview(mXmppConnectionService,message).first, message.getTimeSent(), sender); } builder.setStyle(messagingStyle); } else { if(messages.get(0).getConversation().getMode() == Conversation.MODE_SINGLE) { builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages))); builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get((messages.size() - 1))).first); } else { final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); SpannableString styledString; for (Message message : messages) { final String name = UIHelper.getMessageDisplayName(message); styledString = new SpannableString(name + ": " + message.getBody()); styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0); style.addLine(styledString); } builder.setStyle(style); if(messages.size() == 1) { final String name = UIHelper.getMessageDisplayName(messages.get(0)); styledString = new SpannableString(name + ": " + messages.get(0).getBody()); styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0); builder.setContentText(styledString); } else { builder.setContentText(messages.size() + " " + mXmppConnectionService.getString(R.string.unread_conversations)); } } } }