Notification Tutorial

Using Big View Styles

How to customize big content view

// Supply custom RemoteViews to use instead of the platform template
// in the expanded form
public Builder setCustomBigContentView(RemoteViews contentView);

How to expand big content view by default

refer

A notification's big view appears only when the notification is expanded, which happens when

  • the notification is at the top of the notification drawer, or
  • the user expands the notification with a gesture.

However, there is a trick to push the notification to the top of the list where it would be expanded: setOngoing(true).

How to update notification

refer

// Sets an ID for the notification, so it can be updated
mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());

// Use the SAME Builder for each update.
mNotificationBuilder.setContentText("new text");

// Because the ID remains unchanged, the existing notification is updated.
mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());

How to display big text (longer text)

public Builder setStyle(
    new NotificationCompat.BigTextStyle().bigText(CharSequence cs);

How to fix crash - RemoteServiceException: Bad notification posted from package: Couldn't expand RemoteViews

refer

for unknown reason you are not allowed to reference dimen in the root view of the custom remote view! so you have to hard code it like android:layout_height="128dp"

notification notification expanded

demo

TODO

notification theme is wrong on Android 7 !

Refer