NotificationCompat.DecoratedCustomViewStyle

Added in 1.1.0

class NotificationCompat.DecoratedCustomViewStyle : NotificationCompat.Style


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 setCustomContentView, setCustomBigContentView and setCustomHeadsUpContentView to set the corresponding custom views to display.

To use this style with your Notification, feed it to setStyle 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 TextAppearance_Compat_Notification or TextAppearance_Compat_Notification_Title in your custom views in order to get the correct styling on each platform version.

Summary

Public constructors

Public functions

java-static (Mutable)List<CharSequence!>
@RequiresApi(value = 24)
getTextsFromContentView(context: Context, notification: Notification)

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

Inherited functions

From androidx.core.app.NotificationCompat.Style
Notification?

If this Style object has been set on a notification builder, this method will build that notification and return it.

Unit

Link this rich notification style with a notification builder.

Public constructors

DecoratedCustomViewStyle

Added in 1.1.0
DecoratedCustomViewStyle()

Public functions

getTextsFromContentView

Added in 1.15.0
@RequiresApi(value = 24)
java-static fun getTextsFromContentView(context: Context, notification: Notification): (Mutable)List<CharSequence!>

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

Parameters
context: Context

A Context that will be used to inflate the content view from the notification.

notification: Notification

The notification from which to get texts from its content view.

Returns
(Mutable)List<CharSequence!>

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 bigContentView, then is contentView when no big content view has set, or headsUpContentView when set. Otherwise, returns the empty list.