# CustomTabsServiceConnection

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

*** ** * ** ***


```
abstract class CustomTabsServiceConnection : ServiceConnection
```

<br />

*** ** * ** ***

Abstract `https://developer.android.com/reference/android/content/ServiceConnection.html` to use while binding to a `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService`. Any client implementing this is responsible for handling changes related with the lifetime of the connection like rebinding on disconnect.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsServiceConnection#CustomTabsServiceConnection()()` |

| ### Public functions |
|---|---|
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsServiceConnection#onCustomTabsServiceConnected(android.content.ComponentName,androidx.browser.customtabs.CustomTabsClient)( name: https://developer.android.com/reference/android/content/ComponentName.html, client: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsClient )` Called when a connection to the `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService` has been established. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsServiceConnection#onServiceConnected(android.content.ComponentName,android.os.IBinder)(name: https://developer.android.com/reference/android/content/ComponentName.html, service: https://developer.android.com/reference/android/os/IBinder.html)` |

| ### Inherited functions |
|---|
| From [android.content.ServiceConnection](https://developer.android.com/reference/android/content/ServiceConnection.html) |---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/android/content/ServiceConnection.html#onBindingDied(android.content.ComponentName)(name: https://developer.android.com/reference/android/content/ComponentName.html!)` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/android/content/ServiceConnection.html#onNullBinding(android.content.ComponentName)(name: https://developer.android.com/reference/android/content/ComponentName.html!)` | | `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/android/content/ServiceConnection.html#onServiceDisconnected(android.content.ComponentName)(p: https://developer.android.com/reference/android/content/ComponentName.html!)` | |

## Public constructors

### CustomTabsServiceConnection

Added in 1.2.0

```
CustomTabsServiceConnection()
```

## Public functions

### onCustomTabsServiceConnected

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

```
abstract fun onCustomTabsServiceConnected(
    name: ComponentName,
    client: CustomTabsClient
): Unit
```

Called when a connection to the `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsService` has been established.

| Parameters |
|---|---|
| `name: https://developer.android.com/reference/android/content/ComponentName.html` | The concrete component name of the service that has been connected. |
| `client: https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsClient` | `https://developer.android.com/reference/kotlin/androidx/browser/customtabs/CustomTabsClient` that contains the `https://developer.android.com/reference/android/os/IBinder.html` with which the connection have been established. All further communication should be initiated using this client. |

### onServiceConnected

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

```
fun onServiceConnected(name: ComponentName, service: IBinder): Unit
```