# 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)

*** ** * ** ***


```
public abstract class CustomTabsServiceConnection implements ServiceConnection
```

<br />

*** ** * ** ***

Abstract `https://developer.android.com/reference/android/content/ServiceConnection.html` to use while binding to a `https://developer.android.com/reference/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/androidx/browser/customtabs/CustomTabsServiceConnection#CustomTabsServiceConnection()()` |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsServiceConnection#onCustomTabsServiceConnected(android.content.ComponentName,androidx.browser.customtabs.CustomTabsClient)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/ComponentName.html name, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient client )` Called when a connection to the `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsService` has been established. |
| `final void` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsServiceConnection#onServiceConnected(android.content.ComponentName,android.os.IBinder)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/ComponentName.html name, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/IBinder.html service)` |

| ### Inherited methods |
|---|
| From [android.content.ServiceConnection](https://developer.android.com/reference/android/content/ServiceConnection.html) |---|---| | `void` | `https://developer.android.com/reference/android/content/ServiceConnection.html#onBindingDied(android.content.ComponentName)(https://developer.android.com/reference/android/content/ComponentName.html name)` | | `void` | `https://developer.android.com/reference/android/content/ServiceConnection.html#onNullBinding(android.content.ComponentName)(https://developer.android.com/reference/android/content/ComponentName.html name)` | | `abstract void` | `https://developer.android.com/reference/android/content/ServiceConnection.html#onServiceDisconnected(android.content.ComponentName)(https://developer.android.com/reference/android/content/ComponentName.html p)` | |

## Public constructors

### CustomTabsServiceConnection

Added in 1.2.0

```
public CustomTabsServiceConnection()
```

## Public methods

### onCustomTabsServiceConnected

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

```
public abstract void onCustomTabsServiceConnected(
    @NonNull ComponentName name,
    @NonNull CustomTabsClient client
)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/ComponentName.html name` | The concrete component name of the service that has been connected. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient client` | `https://developer.android.com/reference/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)

```
public final void onServiceConnected(@NonNull ComponentName name, @NonNull IBinder service)
```