Notification.BubbleMetadata.Builder  |  API reference  |  Android Developers


public static final class Notification.BubbleMetadata.Builder
extends Object



Builder to construct a BubbleMetadata object.

Summary

Public constructors

Builder()

This constructor is deprecated. use Builder.Builder(String) for a bubble created via a ShortcutInfo or Builder.Builder(PendingIntent,Icon) for a bubble created via a PendingIntent.

Builder(PendingIntent intent, Icon icon)

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

Builder(String shortcutId)

Creates a BubbleMetadata.Builder based on a ShortcutInfo.

Public methods

Notification.BubbleMetadata build()

Creates the BubbleMetadata defined by this builder.

Notification.BubbleMetadata.Builder setAutoExpandBubble(boolean shouldExpand)

Sets whether the bubble will be posted in its expanded state.

Notification.BubbleMetadata.Builder setDeleteIntent(PendingIntent deleteIntent)

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

Notification.BubbleMetadata.Builder setDesiredHeight(int height)

Sets the desired height in DPs for the expanded content of the bubble.

Notification.BubbleMetadata.Builder setDesiredHeightResId(int heightResId)

Sets the desired height via resId for the expanded content of the bubble.

Notification.BubbleMetadata.Builder setIcon(Icon icon)

Sets the icon for the bubble.

Notification.BubbleMetadata.Builder setIntent(PendingIntent intent)

Sets the intent for the bubble.

Notification.BubbleMetadata.Builder setSuppressNotification(boolean shouldSuppressNotif)

Sets whether the bubble will be posted without the associated notification in the notification shade.

Notification.BubbleMetadata.Builder setSuppressableBubble(boolean suppressBubble)

Indicates whether the bubble should be visually suppressed from the bubble stack if the user is viewing the same content outside of the bubble.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

public Builder (PendingIntent intent, 
                Icon icon)

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.

When the activity is launched from a bubble, Activity.isLaunchedFromBubble() will return with true.

Note that the pending intent used here requires PendingIntent.FLAG_MUTABLE.

Parameters
intent PendingIntent: This value cannot be null.
icon Icon: This value cannot be null.
Throws
NullPointerException if intent is null.
NullPointerException if icon is null.

Public methods

setAutoExpandBubble

public Notification.BubbleMetadata.Builder setAutoExpandBubble (boolean shouldExpand)

Sets whether the bubble will be posted in its expanded state.

This flag has no effect if the app posting the bubble is not in the foreground. The app is considered foreground if it is visible and on the screen, note that a foreground service does not qualify.

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

Setting this flag is optional; it defaults to false.

Parameters
shouldExpand boolean
Returns
Notification.BubbleMetadata.Builder This value cannot be null.

setDesiredHeight

public Notification.BubbleMetadata.Builder setDesiredHeight (int height)

Sets the desired height in DPs for the expanded content of the bubble.

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.

A desired height (in DPs or via resID) is optional.

Parameters
height int
Returns
Notification.BubbleMetadata.Builder This value cannot be null.

setDesiredHeightResId

public Notification.BubbleMetadata.Builder setDesiredHeightResId (int heightResId)

Sets the desired height via resId for the expanded content of the bubble.

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.

A desired height (in DPs or via resID) is optional.

Parameters
heightResId int
Returns
Notification.BubbleMetadata.Builder This value cannot be null.

setSuppressNotification

public Notification.BubbleMetadata.Builder setSuppressNotification (boolean shouldSuppressNotif)

Sets whether the bubble will be posted without the associated notification in the notification shade.

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.

Setting this flag is optional; it defaults to false.

Parameters
shouldSuppressNotif boolean
Returns
Notification.BubbleMetadata.Builder This value cannot be null.

setSuppressableBubble

public Notification.BubbleMetadata.Builder setSuppressableBubble (boolean suppressBubble)

Indicates whether the bubble should be visually suppressed from the bubble stack if the user is viewing the same content outside of the bubble. For example, the user has a bubble with Alice and then opens up the main app and navigates to Alice's page.

To match the activity and the bubble notification, the bubble notification should have a locus id set that matches a locus id set on the activity.

Parameters
suppressBubble boolean
Returns
Notification.BubbleMetadata.Builder This value cannot be null.