Notification multiline

teja picture teja · Nov 6, 2013 · Viewed 47.3k times · Source

How to make a long notification multiline. I am using the below code snippet but its not working:

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
  .setContentTitle(title)
  .setSmallIcon(R.drawable.icon)
  .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
  .setContentText(message)
  .setContentIntent(pIntent);

return mBuilder.build();

Answer

Siddharth_Vyas picture Siddharth_Vyas · Nov 6, 2013

Add this :

NotificationCompat.Builder builder = new NotificationCompat.Builder(
            context);
    Notification notification = builder.setContentIntent(contentIntent)
            .setSmallIcon(icon).setTicker(appname).setWhen(0)
            .setAutoCancel(true).setContentTitle(appname)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
            .setContentText(message).build();

    notificationManager.notify(0, notification);

Also check : Multiline Notification