Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#inhmethods)

# Notification.BubbleMetadata.Builder

*** ** * ** ***

` public static final class Notification.BubbleMetadata.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.Notification.BubbleMetadata.Builder |

<br />

*** ** * ** ***

Builder to construct a `https://developer.android.com/reference/android/app/Notification.BubbleMetadata` object.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder()() ` *This constructor is deprecated. use `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(java.lang.String)` for a bubble created via a `https://developer.android.com/reference/android/content/pm/ShortcutInfo` or `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(android.app.PendingIntent,%20android.graphics.drawable.Icon)` for a bubble created via a `https://developer.android.com/reference/android/app/PendingIntent`.* |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(android.app.PendingIntent,%20android.graphics.drawable.Icon)(https://developer.android.com/reference/android/app/PendingIntent intent, https://developer.android.com/reference/android/graphics/drawable/Icon icon) ` Creates a `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` based on the provided intent and icon. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(java.lang.String)(https://developer.android.com/reference/java/lang/String shortcutId) ` Creates a `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` based on a `https://developer.android.com/reference/android/content/pm/ShortcutInfo`. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#build()() ` Creates the `https://developer.android.com/reference/android/app/Notification.BubbleMetadata` defined by this builder. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setAutoExpandBubble(boolean)(boolean shouldExpand) ` Sets whether the bubble will be posted in its expanded state. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setDeleteIntent(android.app.PendingIntent)(https://developer.android.com/reference/android/app/PendingIntent deleteIntent) ` Sets an intent to send when this bubble is explicitly removed by the user. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setDesiredHeight(int)(int height) ` Sets the desired height in DPs for the expanded content of the bubble. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setDesiredHeightResId(int)(int heightResId) ` Sets the desired height via resId for the expanded content of the bubble. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setIcon(android.graphics.drawable.Icon)(https://developer.android.com/reference/android/graphics/drawable/Icon icon) ` Sets the icon for the bubble. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setIntent(android.app.PendingIntent)(https://developer.android.com/reference/android/app/PendingIntent intent) ` Sets the intent for the bubble. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setSuppressNotification(boolean)(boolean shouldSuppressNotif) ` Sets whether the bubble will be posted **without** the associated notification in the notification shade. |
| ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | ` https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setSuppressableBubble(boolean)(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 ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(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` ` https://developer.android.com/reference/java/lang/Object#wait(long)(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` ` https://developer.android.com/reference/java/lang/Object#wait()() `

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

## Public constructors

### Builder

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

<br />

**This constructor is deprecated.**   

use `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(java.lang.String)` for a bubble created via a `https://developer.android.com/reference/android/content/pm/ShortcutInfo` or `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(android.app.PendingIntent,%20android.graphics.drawable.Icon)` for a bubble created via a `https://developer.android.com/reference/android/app/PendingIntent`.

<br />

<br />

### Builder

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder (PendingIntent intent, 
                Icon icon)
```

Creates a `https://developer.android.com/reference/android/app/Notification.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, `https://developer.android.com/reference/android/app/Activity#isLaunchedFromBubble()` will return with `true`.
Note that the pending intent used here requires PendingIntent.FLAG_MUTABLE.

<br />

<br />

| Parameters ||
|---|---|
| `intent` | `PendingIntent`: This value cannot be `null`. <br /> |
| `icon` | `Icon`: This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if intent is null. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if icon is null. |

### Builder

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder (String shortcutId)
```

Creates a `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` based on a `https://developer.android.com/reference/android/content/pm/ShortcutInfo`. To create a shortcut bubble, ensure that the shortcut associated with the provided `shortcutId` is published as a dynamic shortcut that was built with `https://developer.android.com/reference/android/content/pm/ShortcutInfo.Builder#setLongLived(boolean)` 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.

When the activity is launched from a bubble, `https://developer.android.com/reference/android/app/Activity#isLaunchedFromBubble()` will return with `true`.

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.

<br />

<br />

| Parameters ||
|---|---|
| `shortcutId` | `String`: This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if shortcutId is null. |

**See also:**

- `https://developer.android.com/reference/android/content/pm/ShortcutInfo`
- `https://developer.android.com/reference/android/content/pm/ShortcutInfo.Builder#setLongLived(boolean)`
- `https://developer.android.com/reference/android/content/pm/ShortcutManager#addDynamicShortcuts(java.util.List<android.content.pm.ShortcutInfo>)`

## Public methods

### build

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.BubbleMetadata build ()
```

Creates the `https://developer.android.com/reference/android/app/Notification.BubbleMetadata` defined by this builder.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if required elements have not been set. |

### setAutoExpandBubble

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

<br />

| Parameters ||
|---|---|
| `shouldExpand` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | This value cannot be `null`. <br /> |

### setDeleteIntent

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.BubbleMetadata.Builder setDeleteIntent (PendingIntent deleteIntent)
```

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

Setting a delete intent is optional.

<br />

<br />

| Parameters ||
|---|---|
| `deleteIntent` | `PendingIntent`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | This value cannot be `null`. <br /> |

### setDesiredHeight

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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 `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#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.

<br />

<br />

| Parameters ||
|---|---|
| `height` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setDesiredHeightResId(int)`

### setDesiredHeightResId

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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 `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#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.

<br />

<br />

| Parameters ||
|---|---|
| `heightResId` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#setDesiredHeight(int)`

### setIcon

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.BubbleMetadata.Builder setIcon (Icon icon)
```

Sets the icon for the bubble. Can only be used if the bubble was created via `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(android.app.PendingIntent,%20android.graphics.drawable.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.

It is recommended to use an `https://developer.android.com/reference/android/graphics/drawable/Icon` of type `https://developer.android.com/reference/android/graphics/drawable/Icon#TYPE_URI` or `https://developer.android.com/reference/android/graphics/drawable/Icon#TYPE_URI_ADAPTIVE_BITMAP`

<br />

<br />

| Parameters ||
|---|---|
| `icon` | `Icon`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if this builder was created via `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(java.lang.String)`. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if icon is null. |

### setIntent

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.BubbleMetadata.Builder setIntent (PendingIntent intent)
```

Sets the intent for the bubble.

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.

<br />

<br />

| Parameters ||
|---|---|
| `intent` | `PendingIntent`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if this builder was created via `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder#Builder(java.lang.String)`. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if intent is null. |

### setSuppressNotification

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

<br />

| Parameters ||
|---|---|
| `shouldSuppressNotif` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | This value cannot be `null`. <br /> |

### setSuppressableBubble

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

| Parameters ||
|---|---|
| `suppressBubble` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.BubbleMetadata.Builder` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/Notification.Builder#setLocusId(android.content.LocusId)`
- `https://developer.android.com/reference/android/app/Activity#setLocusContext(android.content.LocusId,%20android.os.Bundle)`