NotificationCompat.BubbleMetadata.Builder

Added in 1.2.0

class NotificationCompat.BubbleMetadata.Builder


Builder to construct a BubbleMetadata object.

Summary

Public constructors

This function is deprecated.

use Builder for a bubble created via a ShortcutInfoCompat or Builder for a bubble created via a PendingIntent.

@RequiresApi(value = 30)
Builder(shortcutId: String)

Creates a BubbleMetadata.Builder based on a ShortcutInfoCompat.

Builder(intent: PendingIntent, icon: IconCompat)

Creates a BubbleMetadata.Builder based on the provided intent and icon.

Public functions

NotificationCompat.BubbleMetadata

Creates the BubbleMetadata defined by this builder.

NotificationCompat.BubbleMetadata.Builder

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 getIntent in a floating window.

NotificationCompat.BubbleMetadata.Builder

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

NotificationCompat.BubbleMetadata.Builder
setDesiredHeight(height: @Dimension(unit = 0) Int)

Sets the desired height in DPs for the app content defined by setIntent, 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

Sets the desired height via resId for the app content defined by setIntent, 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

Sets the icon for the bubble.

NotificationCompat.BubbleMetadata.Builder

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

NotificationCompat.BubbleMetadata.Builder
setSuppressNotification(shouldSuppressNotif: Boolean)

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.

Public constructors

Builder

Added in 1.2.0
Deprecated in 1.5.0
Builder()

Builder

Added in 1.5.0
@RequiresApi(value = 30)
Builder(shortcutId: String)

Creates a BubbleMetadata.Builder based on a ShortcutInfoCompat. To create a shortcut bubble, ensure that the shortcut associated with the provided {@param shortcutId} is published as a dynamic shortcut that was built with setLongLived being true, otherwise your notification will not be able to bubble.

The shortcut icon will be used to represent the bubble when it is collapsed.

The shortcut activity will be used when the bubble is expanded. This will display the shortcut activity in a floating window over the existing foreground activity.

If the shortcut has not been published when the bubble notification is sent, no bubble will be produced. If the shortcut is deleted while the bubble is active, the bubble will be removed.

Throws
java.lang.NullPointerException

if shortcutId is null.

Builder

Added in 1.5.0
Builder(intent: PendingIntent, icon: IconCompat)

Creates a BubbleMetadata.Builder based on the provided intent and icon.

The icon will be used to represent the bubble when it is collapsed. An icon should be representative of the content within the bubble. If your app produces multiple bubbles, the icon should be unique for each of them.

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. The intent should point to a resizable activity.

Throws
java.lang.NullPointerException

if intent is null.

java.lang.NullPointerException

if icon is null.

Public functions

build

Added in 1.2.0
fun build(): NotificationCompat.BubbleMetadata

Creates the BubbleMetadata defined by this builder.

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

setAutoExpandBubble

Added in 1.2.0
fun setAutoExpandBubble(shouldExpand: Boolean): NotificationCompat.BubbleMetadata.Builder

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 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.

setDeleteIntent

Added in 1.2.0
fun setDeleteIntent(deleteIntent: PendingIntent?): NotificationCompat.BubbleMetadata.Builder

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

setDesiredHeight

Added in 1.2.0
fun setDesiredHeight(height: @Dimension(unit = 0) Int): NotificationCompat.BubbleMetadata.Builder

Sets the desired height in DPs for the app content defined by setIntent, 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 was previously called on this builder, the previous value set will be cleared after calling this method, and this value will be used instead.

setDesiredHeightResId

Added in 1.2.0
fun setDesiredHeightResId(heightResId: @DimenRes Int): NotificationCompat.BubbleMetadata.Builder

Sets the desired height via resId for the app content defined by setIntent, 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 was previously called on this builder, the previous value set will be cleared after calling this method, and this value will be used instead.

setIcon

Added in 1.2.0
fun setIcon(icon: IconCompat): NotificationCompat.BubbleMetadata.Builder

Sets the icon for the bubble. Can only be used if the bubble was created via Builder.

The icon will be used to represent the bubble when it is collapsed. An icon should be representative of the content within the bubble. If your app produces multiple bubbles, the icon should be unique for each of them.

It is recommended to use an Icon of type TYPE_URI or TYPE_URI_ADAPTIVE_BITMAP

Throws
java.lang.NullPointerException

if icon is null.

java.lang.IllegalStateException

if this builder was created via Builder.

setIntent

Added in 1.2.0
fun setIntent(intent: PendingIntent): NotificationCompat.BubbleMetadata.Builder

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.

Throws
java.lang.NullPointerException

if intent is null.

java.lang.IllegalStateException

if this builder was created via Builder.

setSuppressNotification

Added in 1.2.0
fun setSuppressNotification(shouldSuppressNotif: Boolean): NotificationCompat.BubbleMetadata.Builder

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.