public class

NotificationCompat.DecoratedCustomViewStyle

extends NotificationCompat.Style

 java.lang.Object

androidx.core.app.NotificationCompat.Style

↳androidx.core.app.NotificationCompat.DecoratedCustomViewStyle

Overview

Notification style for custom views that are decorated by the system.

Instead of providing a notification that is completely custom, a developer can set this style and still obtain system decorations like the notification header with the expand affordance and actions.

Use NotificationCompat.Builder.setCustomContentView(RemoteViews), NotificationCompat.Builder.setCustomBigContentView(RemoteViews) and NotificationCompat.Builder.setCustomHeadsUpContentView(RemoteViews) to set the corresponding custom views to display.

To use this style with your Notification, feed it to NotificationCompat.Builder like so:

 Notification noti = new NotificationCompat.Builder()
     .setSmallIcon(R.drawable.ic_stat_player)
     .setLargeIcon(albumArtBitmap))
     .setCustomContentView(contentView)
     .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
     .build();
 

If you are using this style, consider using the corresponding styles like or in your custom views in order to get the correct styling on each platform version.

Summary

Fields
from NotificationCompat.StylemBuilder
Constructors
publicDecoratedCustomViewStyle()

Methods
public voidapply(NotificationBuilderWithBuilderAccessor builder)

Applies the compat style data to the framework Notification in a backwards compatible way.

public booleandisplayCustomViewInline()

protected java.lang.StringgetClassName()

public static java.util.List<java.lang.CharSequence>getTextsFromContentView(Context context, Notification notification)

A helper method to get texts from a Notification's custom content view made by either NotificationCompat.Builder.setCustomBigContentView(RemoteViews), NotificationCompat.Builder.setCustomContentView(RemoteViews) or NotificationCompat.Builder.setCustomHeadsUpContentView(RemoteViews).

public RemoteViewsmakeBigContentView(NotificationBuilderWithBuilderAccessor builder)

public RemoteViewsmakeContentView(NotificationBuilderWithBuilderAccessor builder)

public RemoteViewsmakeHeadsUpContentView(NotificationBuilderWithBuilderAccessor builder)

from NotificationCompat.StyleaddCompatExtras, applyStandardTemplate, build, buildIntoRemoteViews, clearCompatExtraKeys, createColoredBitmap, extractStyleFromNotification, restoreFromCompatExtras, setBuilder
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public DecoratedCustomViewStyle()

Methods

protected java.lang.String getClassName()

public boolean displayCustomViewInline()

Returns:

Whether custom content views are displayed inline in the style

public void apply(NotificationBuilderWithBuilderAccessor builder)

Applies the compat style data to the framework Notification in a backwards compatible way. All other data should be stored within the Notification's extras.

public RemoteViews makeContentView(NotificationBuilderWithBuilderAccessor builder)

public RemoteViews makeBigContentView(NotificationBuilderWithBuilderAccessor builder)

public RemoteViews makeHeadsUpContentView(NotificationBuilderWithBuilderAccessor builder)

public static java.util.List<java.lang.CharSequence> getTextsFromContentView(Context context, Notification notification)

A helper method to get texts from a Notification's custom content view made by either NotificationCompat.Builder.setCustomBigContentView(RemoteViews), NotificationCompat.Builder.setCustomContentView(RemoteViews) or NotificationCompat.Builder.setCustomHeadsUpContentView(RemoteViews). Note that this method will not look for Notification made by NotificationCompat.Builder.setPublicVersion(Notification).

Parameters:

context: A that will be used to inflate the content view from the notification.
notification: The notification from which to get texts from its content view.

Returns:

A list of text from the notification custom content view made by the above method. Note that the method only returns a list of text from one of the custom view as the above when it set, meaning when multiple custom content views has set in a notification, the returned list will base on the detail of custom content and usage as the priority: First is Notification, then is Notification when no big content view has set, or Notification when set. Otherwise, returns the empty list.