Skip to content Skip to sidebar Skip to footer

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

Solution 1:

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);

Post a Comment for "Android Notification - Custom Inboxstyle (add Line )"