Essential Android Notifications edit forum

Set custom notification - show full content text

If you want have a long text to display in the context, you need to set a custom content.

For example, you have this:

But you wish your text will be fully shown:

All you need to do, is to add a style to your content like below:

private void generateNotification(Context context) {
      String message = "This is a custom notification with a very very very very very very very very very very long text";
      Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), android.R.drawable.ic_dialog_alert);

      NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

      builder.setContentTitle("Title").setContentText(message)
              .setSmallIcon(android.R.drawable.ic_dialog_alert)
              .setLargeIcon(largeIcon)
              .setAutoCancel(true)
              .setWhen(System.currentTimeMillis())
              .setStyle(new NotificationCompat.BigTextStyle().bigText(message));

      Notification notification = builder.build();
      NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
      notificationManager.notify(101, notification);
  }

Table Of Contents
39 ACRA
42 Notifications
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close