# CustomTabsClient

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:customtabs:28.0.0-alpha1  
Summary:[Methods](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#)  

# CustomTabsClient

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
CustomTabsClient
`  
`

extends Object


``


`

|---|---------------------------------------------|
| java.lang.Object                               ||
| ↳ | android.support.customtabs.CustomTabsClient |

<br />

*** ** * ** ***

Class to communicate with a[CustomTabsService](https://developer.android.com/reference/android/support/customtabs/CustomTabsService)and create[CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession)from it.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                              ||
|--------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static boolean`                                                                                            | ` `[bindCustomTabsService](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#bindCustomTabsService(android.content.Context, java.lang.String, android.support.customtabs.CustomTabsServiceConnection))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String packageName, `[CustomTabsServiceConnection](https://developer.android.com/reference/android/support/customtabs/CustomTabsServiceConnection)` connection) ` Bind to a[CustomTabsService](https://developer.android.com/reference/android/support/customtabs/CustomTabsService)using the given package name and[ServiceConnection](https://developer.android.com/reference/android/content/ServiceConnection.html). |
| ` static boolean`                                                                                            | ` `[connectAndInitialize](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#connectAndInitialize(android.content.Context, java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String packageName) ` Connects to the Custom Tabs warmup service, and initializes the browser.                                                                                                                                                                                                                                                                                                                                                                                     |
| ` `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                  | ` `[extraCommand](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#extraCommand(java.lang.String, android.os.Bundle))`(String commandName, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` args) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` static String`                                                                                             | ` `[getPackageName](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#getPackageName(android.content.Context, java.util.List<java.lang.String>))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, List<String> packages) ` Returns the preferred package to use for Custom Tabs, preferring the default VIEW handler.                                                                                                                                                                                                                                                                                                                                                            |
| ` static String`                                                                                             | ` `[getPackageName](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#getPackageName(android.content.Context, java.util.List<java.lang.String>, boolean))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, List<String> packages, boolean ignoreDefault) ` Returns the preferred package to use for Custom Tabs.                                                                                                                                                                                                                                                                                                                                                                 |
| ` `[CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession) | ` `[newSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#newSession(android.support.customtabs.CustomTabsCallback))`(`[CustomTabsCallback](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback)` callback) ` Creates a new session through an ICustomTabsService with the optional callback.                                                                                                                                                                                                                                                                                                                                                                                     |
| ` boolean`                                                                                                   | ` `[warmup](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#warmup(long))`(long flags) ` Warm up the browser process.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### bindCustomTabsService

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean bindCustomTabsService (Context context, 
                String packageName, 
                CustomTabsServiceConnection connection)
```

Bind to a[CustomTabsService](https://developer.android.com/reference/android/support/customtabs/CustomTabsService)using the given package name and[ServiceConnection](https://developer.android.com/reference/android/content/ServiceConnection.html).

<br />

|                                                                                                                                                                                                                                            Parameters                                                                                                                                                                                                                                             ||
|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`     | `Context`:[Context](https://developer.android.com/reference/android/content/Context.html)to use while calling[bindService(Intent, ServiceConnection, int)](https://developer.android.com/reference/android/content/Context.html#bindService(android.content.Intent, android.content.ServiceConnection, int)) <br />                                                                                                                                                                |
| `packageName` | `String`: Package name to set on the[Intent](https://developer.android.com/reference/android/content/Intent.html)for binding. <br />                                                                                                                                                                                                                                                                                                                                               |
| `connection`  | `CustomTabsServiceConnection`:[CustomTabsServiceConnection](https://developer.android.com/reference/android/support/customtabs/CustomTabsServiceConnection)to use when binding. This will return a[CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient)on[#onCustomTabsServiceConnected(ComponentName, CustomTabsClient)](https://developer.android.com/reference/android/support/customtabs/CustomTabsServiceConnection) <br /> |

|                        Returns                        ||
|-----------|--------------------------------------------|
| `boolean` | Whether the binding was successful. <br /> |

### connectAndInitialize

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean connectAndInitialize (Context context, 
                String packageName)
```

Connects to the Custom Tabs warmup service, and initializes the browser. This convenience method connects to the service, and immediately warms up the Custom Tabs implementation. Since service connection is asynchronous, the return code is not the return code of warmup. This call is optional, and clients are encouraged to connect to the service, call`warmup()`and create a session. In this case, calling this method is not necessary.

<br />

|                                                                       Parameters                                                                        ||
|---------------|------------------------------------------------------------------------------------------------------------------------------------------|
| `context`     | `Context`:[Context](https://developer.android.com/reference/android/content/Context.html)to use to connect to the remote service. <br /> |
| `packageName` | `String`: Package name of the target implementation. <br />                                                                              |

|                        Returns                        ||
|-----------|--------------------------------------------|
| `boolean` | Whether the binding was successful. <br /> |

### extraCommand

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Bundle extraCommand (String commandName, 
                Bundle args)
```

<br />

<br />

|           Parameters           ||
|---------------|-----------------|
| `commandName` | `String` <br /> |
| `args`        | `Bundle` <br /> |

|                                     Returns                                      ||
|--------------------------------------------------------------------------|--------|
| [Bundle](https://developer.android.com/reference/android/os/Bundle.html) | <br /> |

### getPackageName

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
String getPackageName (Context context, 
                List<String> packages)
```

Returns the preferred package to use for Custom Tabs, preferring the default VIEW handler.

<br />

|          Parameters          ||
|------------|------------------|
| `context`  | `Context` <br /> |
| `packages` | `List` <br />    |

|     Returns      ||
|----------|--------|
| `String` | <br /> |

**See also:**

- [ERROR(/#getPackageName(Context, List, boolean))](https://developer.android.com/)  

### getPackageName

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
String getPackageName (Context context, 
                List<String> packages, 
                boolean ignoreDefault)
```

Returns the preferred package to use for Custom Tabs. The preferred package name is the default VIEW intent handler as long as it supports Custom Tabs. To modify this preferred behavior, set`ignoreDefault`to true and give a non empty list of package names in`packages`.

<br />

|                                                                     Parameters                                                                     ||
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `context`       | `Context`:[Context](https://developer.android.com/reference/android/content/Context.html)to use for querying the packages. <br /> |
| `packages`      | `List`: Ordered list of packages to test for Custom Tabs support, in decreasing order of priority. <br />                         |
| `ignoreDefault` | `boolean`: If set, the default VIEW handler won't get priority over other browsers. <br />                                        |

|                                     Returns                                     ||
|----------|-----------------------------------------------------------------------|
| `String` | The preferred package name for handling Custom Tabs, or`null`. <br /> |

### newSession

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CustomTabsSession newSession (CustomTabsCallback callback)
```

Creates a new session through an ICustomTabsService with the optional callback. This session can be used to associate any related communication through the service with an intent and then later with a Custom Tab. The client can then send later service calls or intents to through same session-intent-Custom Tab association.

<br />

|                                                                                            Parameters                                                                                            ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `callback` | `CustomTabsCallback`: The callback through which the client will receive updates about the created session. Can be null. All the callbacks will be received on the UI thread. <br /> |

|                                                                                                                            Returns                                                                                                                            ||
|-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession) | The session object that was created as a result of the transaction. The client can use this to relay session specific calls. Null on error. <br /> |

### warmup

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean warmup (long flags)
```

Warm up the browser process. Allows the browser application to pre-initialize itself in the background. Significantly speeds up URL opening in the browser. This is asynchronous and can be called several times.

<br />

|                    Parameters                    ||
|---------|-----------------------------------------|
| `flags` | `long`: Reserved for future use. <br /> |

|                       Returns                        ||
|-----------|-------------------------------------------|
| `boolean` | Whether the warmup was successful. <br /> |

-

  ## Annotations

  - [CustomTabsService.Relation](https://developer.android.com/reference/android/support/customtabs/CustomTabsService.Relation)
  - [CustomTabsService.Result](https://developer.android.com/reference/android/support/customtabs/CustomTabsService.Result)
-

  ## Classes

  - [CustomTabsCallback](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback)
  - [CustomTabsClient](https://developer.android.com/reference/android/support/customtabs/CustomTabsClient)
  - [CustomTabsIntent](https://developer.android.com/reference/android/support/customtabs/CustomTabsIntent)
  - [CustomTabsIntent.Builder](https://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder)
  - [CustomTabsService](https://developer.android.com/reference/android/support/customtabs/CustomTabsService)
  - [CustomTabsServiceConnection](https://developer.android.com/reference/android/support/customtabs/CustomTabsServiceConnection)
  - [CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession)
  - [CustomTabsSessionToken](https://developer.android.com/reference/android/support/customtabs/CustomTabsSessionToken)
  - [PostMessageService](https://developer.android.com/reference/android/support/customtabs/PostMessageService)
  - [PostMessageServiceConnection](https://developer.android.com/reference/android/support/customtabs/PostMessageServiceConnection)
  - [R](https://developer.android.com/reference/android/support/customtabs/R)
  - [R.anim](https://developer.android.com/reference/android/support/customtabs/R.anim)
  - [R.attr](https://developer.android.com/reference/android/support/customtabs/R.attr)
  - [R.bool](https://developer.android.com/reference/android/support/customtabs/R.bool)
  - [R.color](https://developer.android.com/reference/android/support/customtabs/R.color)
  - [R.dimen](https://developer.android.com/reference/android/support/customtabs/R.dimen)
  - [R.drawable](https://developer.android.com/reference/android/support/customtabs/R.drawable)
  - [R.id](https://developer.android.com/reference/android/support/customtabs/R.id)
  - [R.integer](https://developer.android.com/reference/android/support/customtabs/R.integer)
  - [R.layout](https://developer.android.com/reference/android/support/customtabs/R.layout)
  - [R.string](https://developer.android.com/reference/android/support/customtabs/R.string)
  - [R.style](https://developer.android.com/reference/android/support/customtabs/R.style)
  - [R.styleable](https://developer.android.com/reference/android/support/customtabs/R.styleable)
  - [TrustedWebUtils](https://developer.android.com/reference/android/support/customtabs/TrustedWebUtils)