It's happening now, watch the livestream.

NotificationCompat.BubbleMetadata.Builder

public static final class NotificationCompat.BubbleMetadata.Builder
extends Object

java.lang.Object
   ↳ androidx.core.app.NotificationCompat.BubbleMetadata.Builder


Builder to construct a NotificationCompat.BubbleMetadata object.

Summary

Public constructors

NotificationCompat.BubbleMetadata.Builder()

Constructs a new builder object.

Public methods

NotificationCompat.BubbleMetadata build()

Creates the NotificationCompat.BubbleMetadata defined by this builder.

NotificationCompat.BubbleMetadata.Builder setAutoExpandBubble(boolean shouldExpand)

If set and the app creating the bubble is in the foreground, the bubble will be posted in its expanded state, with the contents of NotificationCompat.BubbleMetadata.getIntent() in a floating window.

NotificationCompat.BubbleMetadata.Builder setDeleteIntent(PendingIntent deleteIntent)

Sets an optional intent to send when this bubble is explicitly removed by the user.

NotificationCompat.BubbleMetadata.Builder setDesiredHeight(int height)

Sets the desired height in DPs for the app content defined by setIntent(PendingIntent), this height may not be respected if there is not enough space on the screen or if the provided height is too small to be useful.

NotificationCompat.BubbleMetadata.Builder setDesiredHeightResId(int heightResId)

Sets the desired height via resId for the app content defined by setIntent(PendingIntent), this height may not be respected if there is not enough space on the screen or if the provided height is too small to be useful.

NotificationCompat.BubbleMetadata.Builder setIcon(IconCompat icon)

Sets the icon that will represent the bubble when it is collapsed.

NotificationCompat.BubbleMetadata.Builder setIntent(PendingIntent intent)

Sets the intent that will be used when the bubble is expanded.

NotificationCompat.BubbleMetadata.Builder setSuppressNotification(boolean shouldSuppressNotif)

If set and the app posting the bubble is in the foreground, the bubble will be posted without the associated notification in the notification shade.

Inherited methods

Public constructors

NotificationCompat.BubbleMetadata.Builder

public NotificationCompat.BubbleMetadata.Builder ()

Constructs a new builder object.

Public methods

build

public NotificationCompat.BubbleMetadata build ()

Creates the NotificationCompat.BubbleMetadata defined by this builder.

Will throw IllegalStateException if required fields have not been set on this builder.

Returns
NotificationCompat.BubbleMetadata

setAutoExpandBubble

public NotificationCompat.BubbleMetadata.Builder setAutoExpandBubble (boolean shouldExpand)

If set and the app creating the bubble is in the foreground, the bubble will be posted in its expanded state, with the contents of NotificationCompat.BubbleMetadata.getIntent() in a floating window.

If the app creating the bubble is not in the foreground this flag has no effect.

Generally this flag should only be set if the user has performed an action to request or create a bubble.

Parameters
shouldExpand boolean

Returns
NotificationCompat.BubbleMetadata.Builder

setDeleteIntent

public NotificationCompat.BubbleMetadata.Builder setDeleteIntent (PendingIntent deleteIntent)

Sets an optional intent to send when this bubble is explicitly removed by the user.

Parameters
deleteIntent PendingIntent

Returns
NotificationCompat.BubbleMetadata.Builder

setDesiredHeight

public NotificationCompat.BubbleMetadata.Builder setDesiredHeight (int height)

Sets the desired height in DPs for the app content defined by setIntent(PendingIntent), this height may not be respected if there is not enough space on the screen or if the provided height is too small to be useful.

If setDesiredHeightResId(int) was previously called on this builder, the previous value set will be cleared after calling this method, and this value will be used instead.

Parameters
height int

Returns
NotificationCompat.BubbleMetadata.Builder

setDesiredHeightResId

public NotificationCompat.BubbleMetadata.Builder setDesiredHeightResId (int heightResId)

Sets the desired height via resId for the app content defined by setIntent(PendingIntent), this height may not be respected if there is not enough space on the screen or if the provided height is too small to be useful.

If setDesiredHeight(int) was previously called on this builder, the previous value set will be cleared after calling this method, and this value will be used instead.

Parameters
heightResId int

Returns
NotificationCompat.BubbleMetadata.Builder

setIcon

public NotificationCompat.BubbleMetadata.Builder setIcon (IconCompat icon)

Sets the icon that will represent the bubble when it is collapsed.

An icon is required and should be representative of the content within the bubble. If your app produces multiple bubbles, the image should be unique for each of them.

The shape of a bubble icon is adaptive and can match the device theme. If your icon is bitmap-based, you should create it using IconCompat.createWithAdaptiveBitmap(Bitmap), otherwise this method will throw. If your icon is not bitmap-based, you should expect that the icon will be tinted.

Parameters
icon IconCompat

Returns
NotificationCompat.BubbleMetadata.Builder

setIntent

public NotificationCompat.BubbleMetadata.Builder setIntent (PendingIntent intent)

Sets the intent that will be used when the bubble is expanded. This will display the app content in a floating window over the existing foreground activity.

Parameters
intent PendingIntent

Returns
NotificationCompat.BubbleMetadata.Builder

setSuppressNotification

public NotificationCompat.BubbleMetadata.Builder setSuppressNotification (boolean shouldSuppressNotif)

If set and the app posting the bubble is in the foreground, the bubble will be posted without the associated notification in the notification shade.

If the app posting the bubble is not in the foreground this flag has no effect.

Generally this flag should only be set if the user has performed an action to request or create a bubble, or if the user has seen the content in the notification and the notification is no longer relevant.

Parameters
shouldSuppressNotif boolean

Returns
NotificationCompat.BubbleMetadata.Builder