SemyonM
SemyonM

Reputation: 135

Android notification - custom inboxstyle (add line )

I'd like to create a create expandable notification, in the pretty much gmail-like style. In general, using NotificationCompat.InboxStyle would be enough. But i need to add an icon in each line. Pretty much like Whatsapp do. See the screenshot enter image description here Any ideas how to implement it? Besides custom layout with RemoteViews

Upvotes: 1

Views: 904

Answers (1)

gitter
gitter

Reputation: 1726

Quickly wrote some poor code and I have emojis everywhere.

String emoji = new String(Character.toChars(0x1F60A));
Notification noti = new Notification.Builder(this)
            .setContentTitle("5 New mails from " + emoji)
            .setContentText(emoji)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setStyle(new Notification.InboxStyle()
                    .setBigContentTitle(emoji)
                    .addLine(emoji)
                    .addLine(emoji)
                    .setSummaryText(emoji))
            .build();

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, noti);

Upvotes: 1

Related Questions