# CustomTabsSession

Artifact: [androidx.browser:browser](https://developer.android.com/jetpack/androidx/releases/browser) [View Source](https://cs.android.com/search?q=file:androidx/browser/customtabs/CustomTabsSession.java+class:androidx.browser.customtabs.CustomTabsSession) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

*** ** * ** ***

<br />

```
class CustomTabsSession
```

<br />

*** ** * ** ***

A class to be used for Custom Tabs related communication. Clients that want to launch Custom Tabs can use this class exclusively to handle all related communication.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession.PendingSession` A class to be used instead of `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession` when a Custom Tab is launched before a Service connection is established. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession` | `@https://developer.android.com/reference/kotlin/androidx/annotation/VisibleForTesting https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#createMockSessionForTesting(android.content.ComponentName)(componentName: https://developer.android.com/reference/android/content/ComponentName.html)` Provides browsers a way to generate a mock `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession` for testing purposes. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle)(extras: https://developer.android.com/reference/android/os/Bundle.html)` Returns whether the Engagement Signals API is available. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List<android.os.Bundle>)( url: https://developer.android.com/reference/android/net/Uri.html?, extras: https://developer.android.com/reference/android/os/Bundle.html?, otherLikelyBundles: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/os/Bundle.html!>? )` Tells the browser of a likely future navigation to a URL. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService.Result https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle)(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, extras: https://developer.android.com/reference/android/os/Bundle.html?)` Sends a postMessage request using the origin communicated via `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService#requestPostMessageChannel(androidx.browser.customtabs.CustomTabsSessionToken,android.net.Uri)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/browser/customtabs/ExperimentalPrefetch https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#prefetch(android.net.Uri,androidx.browser.customtabs.PrefetchOptions)(url: https://developer.android.com/reference/android/net/Uri.html, options: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/PrefetchOptions)` Request the browser to start navigational prefetch to the page that will be used for future navigations. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/browser/customtabs/ExperimentalPrefetch https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#prefetch(java.util.List<android.net.Uri>,androidx.browser.customtabs.PrefetchOptions)(urls: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html!>, options: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/PrefetchOptions)` Request the browser to start navigational prefetch to the pages that will be used for future navigations. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#receiveFile(android.net.Uri,int,android.os.Bundle)(uri: https://developer.android.com/reference/android/net/Uri.html, purpose: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, extras: https://developer.android.com/reference/android/os/Bundle.html?)` Passes an URI of a file, e.g. in order to pass a large bitmap to be displayed in the Custom Tabs provider. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri)(postMessageOrigin: https://developer.android.com/reference/android/net/Uri.html)` Sends a request to create a two way postMessage channel between the client and the browser. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle)( postMessageOrigin: https://developer.android.com/reference/android/net/Uri.html, postMessageTargetOrigin: https://developer.android.com/reference/android/net/Uri.html?, extras: https://developer.android.com/reference/android/os/Bundle.html )` Sends a request to create a two way postMessage channel between the client and the browser with specifying the target origin to communicate with. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setActionButton(android.graphics.Bitmap,java.lang.String)(icon: https://developer.android.com/reference/android/graphics/Bitmap.html, description: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` This sets the action button on the toolbar with ID `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsIntent#TOOLBAR_ACTION_BUTTON_ID()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsFeatures.ENGAGEMENT_SIGNALS, enforcement = "androidx.browser.customtabs.CustomTabsSession#isEngagementSignalsApiAvailable") https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setEngagementSignalsCallback(androidx.browser.customtabs.EngagementSignalsCallback,android.os.Bundle)( callback: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback, extras: https://developer.android.com/reference/android/os/Bundle.html )` Sets an `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` to receive callbacks for events related to the user's engagement with webpage within the tab. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsFeatures.ENGAGEMENT_SIGNALS, enforcement = "androidx.browser.customtabs.CustomTabsSession#isEngagementSignalsApiAvailable") https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setEngagementSignalsCallback(java.util.concurrent.Executor,androidx.browser.customtabs.EngagementSignalsCallback,android.os.Bundle)( executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback, extras: https://developer.android.com/reference/android/os/Bundle.html )` Sets an `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` to receive callbacks for events related to the user's engagement with webpage within the tab. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setSecondaryToolbarSwipeUpGesture(android.app.PendingIntent)(pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html?)` Sets a `https://developer.android.com/reference/android/app/PendingIntent.html` object to be sent when the user swipes up from the secondary (bottom) toolbar. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent)( remoteViews: https://developer.android.com/reference/android/widget/RemoteViews.html?, clickableIDs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>?, pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html? )` Updates the `https://developer.android.com/reference/android/widget/RemoteViews.html` of the secondary toolbar in an existing custom tab session. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[setToolbarItem](https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setToolbarItem(int,android.graphics.Bitmap,java.lang.String))(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, icon: https://developer.android.com/reference/android/graphics/Bitmap.html, description: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` **This function is deprecated.** Use CustomTabsSession#setSecondaryToolbarViews(RemoteViews, int\[\], PendingIntent) <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle)( @https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService.Relation relation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, origin: https://developer.android.com/reference/android/net/Uri.html, extras: https://developer.android.com/reference/android/os/Bundle.html? )` Requests to validate a relationship between the application and an origin. |

## Public functions

### createMockSessionForTesting

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
@VisibleForTesting
java-static fun createMockSessionForTesting(componentName: ComponentName): CustomTabsSession
```

Provides browsers a way to generate a mock `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession` for testing purposes.

| Parameters |
|---|---|
| `componentName: https://developer.android.com/reference/android/content/ComponentName.html` | The component the session should be created for. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession` | A mock session with no functionality. |

### isEngagementSignalsApiAvailable

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/browser#1.6.0)

```
fun isEngagementSignalsApiAvailable(extras: Bundle): Boolean
```

Returns whether the Engagement Signals API is available. The availability of the Engagement Signals API may change at runtime. If an `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` has been set, an `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback#onSessionEnded(boolean,android.os.Bundle)` signal will be sent if the API becomes unavailable later.

| Parameters |
|---|---|
| `extras: https://developer.android.com/reference/android/os/Bundle.html` | Reserved for future use. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the Engagement Signals API is available. A false value means `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setEngagementSignalsCallback(androidx.browser.customtabs.EngagementSignalsCallback,android.os.Bundle)` will return false and not set the callback. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/os/RemoteException.html` | If the Service dies while responding to the request. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | If this method isn't supported by the Custom Tabs implementation. |

### mayLaunchUrl

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
fun mayLaunchUrl(
    url: Uri?,
    extras: Bundle?,
    otherLikelyBundles: (Mutable)List<Bundle!>?
): Boolean
```

Tells the browser of a likely future navigation to a URL. The most likely URL has to be specified first. Optionally, a list of other likely URLs can be provided. They are treated as less likely than the first one, and have to be sorted in decreasing priority order. These additional URLs may be ignored. All previous calls to this method will be deprioritized.

| Parameters |
|---|---|
| `url: https://developer.android.com/reference/android/net/Uri.html?` | Most likely URL, may be `null` if `otherLikelyBundles` is provided. |
| `extras: https://developer.android.com/reference/android/os/Bundle.html?` | Reserved for future use. |
| `otherLikelyBundles: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/os/Bundle.html!>?` | Other likely destinations, sorted in decreasing likelihood order. Inside each Bundle, the client should provide a `https://developer.android.com/reference/android/net/Uri.html` using `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService#KEY_URL()` with `https://developer.android.com/reference/android/os/Bundle.html#putParcelable(java.lang.String, android.os.Parcelable)`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true for success. |

### postMessage

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
@CustomTabsService.Result
fun postMessage(message: String, extras: Bundle?): Int
```

Sends a postMessage request using the origin communicated via `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService#requestPostMessageChannel(androidx.browser.customtabs.CustomTabsSessionToken,android.net.Uri)`. Fails when called before `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/PostMessageServiceConnection#notifyMessageChannelReady(android.os.Bundle)` is received on the client side.

| Parameters |
|---|---|
| `message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The message that is being sent. |
| `extras: https://developer.android.com/reference/android/os/Bundle.html?` | Reserved for future use. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | An integer constant about the postMessage request result. Will return `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService#RESULT_SUCCESS()` if successful. |

### prefetch

Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/browser#1.9.0)

```
@ExperimentalPrefetch
fun prefetch(url: Uri, options: PrefetchOptions): Unit
```

Request the browser to start navigational prefetch to the page that will be used for future navigations.

| Parameters |
|---|---|
| `url: https://developer.android.com/reference/android/net/Uri.html` | The url to be prefetched for upcoming navigations. |
| `options: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/PrefetchOptions` | The option used for prefetch request. Please see `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/PrefetchOptions`. |

### prefetch

Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/browser#1.9.0)

```
@ExperimentalPrefetch
fun prefetch(urls: (Mutable)List<Uri!>, options: PrefetchOptions): Unit
```

Request the browser to start navigational prefetch to the pages that will be used for future navigations.

| Parameters |
|---|---|
| `urls: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html!>` | The urls to be prefetched for upcoming navigations. |
| `options: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/PrefetchOptions` | The option used for prefetch request. Please see `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/PrefetchOptions`. |

### receiveFile

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
fun receiveFile(uri: Uri, purpose: Int, extras: Bundle?): Boolean
```

Passes an URI of a file, e.g. in order to pass a large bitmap to be displayed in the Custom Tabs provider. Prior to calling this method, the client needs to grant a read permission to the target Custom Tabs provider via `https://developer.android.com/reference/android/content/Context.html#grantUriPermission(java.lang.String, android.net.Uri, int)`. The file is read and processed (where applicable) synchronously, therefore it's recommended to call this method on a background thread.

| Parameters |
|---|---|
| `uri: https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/android/net/Uri.html` of the file. |
| `purpose: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Purpose of transferring this file, one of the constants enumerated in `CustomTabsService#FilePurpose`. |
| `extras: https://developer.android.com/reference/android/os/Bundle.html?` | Reserved for future use. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the file was received successfully. |

### requestPostMessageChannel

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
fun requestPostMessageChannel(postMessageOrigin: Uri): Boolean
```

Sends a request to create a two way postMessage channel between the client and the browser.

| Parameters |
|---|---|
| `postMessageOrigin: https://developer.android.com/reference/android/net/Uri.html` | A origin that the client is requesting to be identified as during the postMessage communication. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the implementation accepted the request. Note that returning true here doesn't mean an origin has already been assigned as the validation is asynchronous. |

### requestPostMessageChannel

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/browser#1.6.0)

```
fun requestPostMessageChannel(
    postMessageOrigin: Uri,
    postMessageTargetOrigin: Uri?,
    extras: Bundle
): Boolean
```

Sends a request to create a two way postMessage channel between the client and the browser with specifying the target origin to communicate with.

| Parameters |
|---|---|
| `postMessageOrigin: https://developer.android.com/reference/android/net/Uri.html` | A origin that the client is requesting to be identified as during the postMessage communication. |
| `postMessageTargetOrigin: https://developer.android.com/reference/android/net/Uri.html?` | The target Origin to establish the postMessage communication with. |
| `extras: https://developer.android.com/reference/android/os/Bundle.html` | Reserved for future use. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the implementation accepted the request. Note that returning true here doesn't mean an origin has already been assigned as the validation is asynchronous. |

### setActionButton

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
fun setActionButton(icon: Bitmap, description: String): Boolean
```

This sets the action button on the toolbar with ID `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsIntent#TOOLBAR_ACTION_BUTTON_ID()`.

| Parameters |
|---|---|
| `icon: https://developer.android.com/reference/android/graphics/Bitmap.html` | The new icon of the action button. |
| `description: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Content description of the action button. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setToolbarItem(int,android.graphics.Bitmap,java.lang.String)` |   |

### setEngagementSignalsCallback

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/browser#1.6.0)

```
@RequiresFeature(name = CustomTabsFeatures.ENGAGEMENT_SIGNALS, enforcement = "androidx.browser.customtabs.CustomTabsSession#isEngagementSignalsApiAvailable")
fun setEngagementSignalsCallback(
    callback: EngagementSignalsCallback,
    extras: Bundle
): Boolean
```

Sets an `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` to receive callbacks for events related to the user's engagement with webpage within the tab. Note that the callback will be executed on the main thread using `https://developer.android.com/reference/android/os/Looper.html#getMainLooper()`. To specify the execution thread, use `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setEngagementSignalsCallback(java.util.concurrent.Executor,androidx.browser.customtabs.EngagementSignalsCallback,android.os.Bundle)`.

| Parameters |
|---|---|
| `callback: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` | The `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` to receive the user engagement signals. |
| `extras: https://developer.android.com/reference/android/os/Bundle.html` | Reserved for future use. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the callback connection is allowed. If false, no callbacks will be called for this session. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/os/RemoteException.html` | If the Service dies while responding to the request. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | If this method isn't supported by the Custom Tabs implementation. |

### setEngagementSignalsCallback

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/browser#1.6.0)

```
@RequiresFeature(name = CustomTabsFeatures.ENGAGEMENT_SIGNALS, enforcement = "androidx.browser.customtabs.CustomTabsSession#isEngagementSignalsApiAvailable")
fun setEngagementSignalsCallback(
    executor: Executor,
    callback: EngagementSignalsCallback,
    extras: Bundle
): Boolean
```

Sets an `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` to receive callbacks for events related to the user's engagement with webpage within the tab.

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` to be used to execute the callbacks. |
| `callback: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` | The `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/EngagementSignalsCallback` to receive the user engagement signals. |
| `extras: https://developer.android.com/reference/android/os/Bundle.html` | Reserved for future use. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the callback connection is allowed. If false, no callbacks will be called for this session. |

| Throws |
|---|---|
| `https://developer.android.com/reference/android/os/RemoteException.html` | If the Service dies while responding to the request. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | If this method isn't supported by the Custom Tabs implementation. |

### setSecondaryToolbarSwipeUpGesture

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/browser#1.7.0)

```
fun setSecondaryToolbarSwipeUpGesture(pendingIntent: PendingIntent?): Boolean
```

Sets a `https://developer.android.com/reference/android/app/PendingIntent.html` object to be sent when the user swipes up from the secondary (bottom) toolbar.

| Parameters |
|---|---|
| `pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html?` | `https://developer.android.com/reference/android/app/PendingIntent.html` to send. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the update succeeded. |

### setSecondaryToolbarViews

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
fun setSecondaryToolbarViews(
    remoteViews: RemoteViews?,
    clickableIDs: IntArray<Int>?,
    pendingIntent: PendingIntent?
): Boolean
```

Updates the `https://developer.android.com/reference/android/widget/RemoteViews.html` of the secondary toolbar in an existing custom tab session.

| Parameters |
|---|---|
| `remoteViews: https://developer.android.com/reference/android/widget/RemoteViews.html?` | The updated `https://developer.android.com/reference/android/widget/RemoteViews.html` that will be shown in secondary toolbar. If null, the current secondary toolbar will be dismissed. |
| `clickableIDs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>?` | The ids of clickable views. The onClick event of these views will be handled by custom tabs. |
| `pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html?` | The `https://developer.android.com/reference/android/app/PendingIntent.html` that will be sent when the user clicks on one of the `https://developer.android.com/reference/android/view/View.html`s in clickableIDs. |

### setToolbarItem

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0) Deprecated in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
fun [setToolbarItem](https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsSession#setToolbarItem(int,android.graphics.Bitmap,java.lang.String))(id: Int, icon: Bitmap, description: String): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use CustomTabsSession#setSecondaryToolbarViews(RemoteViews, int\[\], PendingIntent)

Updates the visuals for toolbar items. Will only succeed if a custom tab created using this session is in the foreground in browser and the given id is valid.

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The id for the item to update. |
| `icon: https://developer.android.com/reference/android/graphics/Bitmap.html` | The new icon of the toolbar item. |
| `description: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Content description of the toolbar item. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the update succeeded. |

### validateRelationship

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/browser#1.2.0)

```
fun validateRelationship(
    @CustomTabsService.Relation relation: Int,
    origin: Uri,
    extras: Bundle?
): Boolean
```

Requests to validate a relationship between the application and an origin.

See [here](https://developers.google.com/digital-asset-links/v1/getting-started) for documentation about Digital Asset Links. This methods requests the browser to verify a relation with the calling application, to grant the associated rights.

If this method returns `true`, the validation result will be provided through `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsCallback#onRelationshipValidationResult(int,android.net.Uri,boolean,android.os.Bundle)`. Otherwise the request didn't succeed. The client must call `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsClient#warmup(long)` before this.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService.Relation relation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Relation to check, must be one of the `CustomTabsService#RELATION_* ` constants. |
| `origin: https://developer.android.com/reference/android/net/Uri.html` | Origin. |
| `extras: https://developer.android.com/reference/android/os/Bundle.html?` | Reserved for future use. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the request has been submitted successfully. |