https://blog.stylingandroid.com/nougat-messaging-style-notifications/
-
Bundled Notification 이란 녀석은 Notification 들을 각각 만들고, Notification framework 를 사용하여 grouping 을 하는 개념이라면,
Messaging Style Notification 은 Notification 하나에 여러 Message 를 담는 것을 의미한다.
-
Messaging Style Notification 은 Nougat 부터 사용 가능하다.
-
NotificationCompay.MessagingStyle messagingStyle = buildMessageList(messages);
Notification notification = new NotificationCompat.Builder(context)
.setStyle(messagingStyle)
.setSmallIcon(R.drawable.ic_message)
.build();
notificationManager.notify(NOTI_ID, notification);
private NotificationCompat.MessagingStyle buildMessageList(List<String> messages){
NotificationCompat.MessagingStyle messagingStyle = new NotificationCompat.MessagingStyle(DISPLAY_NAME)
.setConversationTitle(“Messenger”); // 상단에 표시된다.
for (String message : messages){
messagingStyle.addMessage(message, System.currentTimeInMillies(), SENDER_NAME);
}
return messagingStyle;
}
-
Messaging Styling 을 사용하게 되면 Nougat 이전 버전에서는 아래와 같이 표시된다.
따라서 코드 분기가 필요하다.
'프로그래밍 놀이터 > 안드로이드, Java' 카테고리의 다른 글
[android] ConstraintLayout Tutorial (0) | 2018.03.03 |
---|---|
[android] Bundled Notification Tutorial (3) | 2018.03.02 |
[android] Direct Reply Tutorial (0) | 2018.02.28 |
[android] App Shortcuts Tutorial (0) | 2018.02.25 |
[android] Google Sign In 서버로 검증하기 #3 (0) | 2018.02.24 |
댓글