# CustomTabsCallback

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:[Constants](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#constants)\|[Ctors](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#pubctors)\|[Methods](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#)  

# CustomTabsCallback

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

extends Object


``


`

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

<br />

*** ** * ** ***

A callback class for custom tabs client to get messages regarding events in their custom tabs. In the implementation, all callbacks are sent to the UI thread for the client.

## Summary

|                                                                                                                      ### Constants                                                                                                                      ||
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [NAVIGATION_ABORTED](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#NAVIGATION_ABORTED) Sent when loading was aborted by a user action before it finishes like clicking on a link or refreshing the page. |
| `int` | [NAVIGATION_FAILED](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#NAVIGATION_FAILED) Sent when the tab couldn't finish loading due to a failure.                                                         |
| `int` | [NAVIGATION_FINISHED](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#NAVIGATION_FINISHED) Sent when the tab has finished loading a page.                                                                  |
| `int` | [NAVIGATION_STARTED](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#NAVIGATION_STARTED) Sent when the tab has started loading a page.                                                                     |
| `int` | [TAB_HIDDEN](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#TAB_HIDDEN) Sent when the tab becomes hidden.                                                                                                 |
| `int` | [TAB_SHOWN](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#TAB_SHOWN) Sent when the tab becomes visible.                                                                                                  |

|                                                           ### Public constructors                                                           ||
|------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[CustomTabsCallback](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#CustomTabsCallback())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                     ### Public methods                                                                                                                                                                                                                                                                                                                                                                     ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[extraCallback](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#extraCallback(java.lang.String, android.os.Bundle))`(String callbackName, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` args) ` Unsupported callbacks that may be provided by the implementation.                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` void` | ` `[onMessageChannelReady](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#onMessageChannelReady(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Called when[CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession)has requested a postMessage channel through[requestPostMessageChannel(CustomTabsSessionToken, android.net.Uri)](https://developer.android.com/reference/android/support/customtabs/CustomTabsService#requestPostMessageChannel(android.support.customtabs.CustomTabsSessionToken, android.net.Uri))and the channel is ready for sending and receiving messages on both ends. |
| ` void` | ` `[onNavigationEvent](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#onNavigationEvent(int, android.os.Bundle))`(int navigationEvent, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` To be called when a navigation event happens.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` void` | ` `[onPostMessage](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#onPostMessage(java.lang.String, android.os.Bundle))`(String message, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Called when a tab controlled by this[CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession)has sent a postMessage.                                                                                                                                                                                                                                                                                                           |
| ` void` | ` `[onRelationshipValidationResult](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#onRelationshipValidationResult(int, android.net.Uri, boolean, android.os.Bundle))`(int relation, `[Uri](https://developer.android.com/reference/android/net/Uri.html)` requestedOrigin, boolean result, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Called when a relationship validation result is available.                                                                                                                                                                                                                                                                 |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback#)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() `                    | ||

## Constants

### NAVIGATION_ABORTED

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

```
int NAVIGATION_ABORTED
```

Sent when loading was aborted by a user action before it finishes like clicking on a link or refreshing the page.

<br />

Constant Value: 4 (0x00000004)  

### NAVIGATION_FAILED

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

```
int NAVIGATION_FAILED
```

Sent when the tab couldn't finish loading due to a failure.

<br />

Constant Value: 3 (0x00000003)  

### NAVIGATION_FINISHED

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

```
int NAVIGATION_FINISHED
```

Sent when the tab has finished loading a page.

<br />

Constant Value: 2 (0x00000002)  

### NAVIGATION_STARTED

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

```
int NAVIGATION_STARTED
```

Sent when the tab has started loading a page.

<br />

Constant Value: 1 (0x00000001)  

### TAB_HIDDEN

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

```
int TAB_HIDDEN
```

Sent when the tab becomes hidden.

<br />

Constant Value: 6 (0x00000006)  

### TAB_SHOWN

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

```
int TAB_SHOWN
```

Sent when the tab becomes visible.

<br />

Constant Value: 5 (0x00000005)

## Public constructors

### CustomTabsCallback

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

```
CustomTabsCallback ()
```

<br />

<br />

## Public methods

### extraCallback

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

```
void extraCallback (String callbackName, 
                Bundle args)
```

Unsupported callbacks that may be provided by the implementation.

**Note:** Clients should**never**rely on this callback to be called and/or to have a defined behavior, as it is entirely implementation-defined and not supported.

This can be used by implementations to add extra callbacks, for testing or experimental purposes.

<br />

|                          Parameters                          ||
|----------------|----------------------------------------------|
| `callbackName` | `String`: Name of the extra callback. <br /> |
| `args`         | `Bundle`: Arguments for the calback <br />   |

### onMessageChannelReady

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

```
void onMessageChannelReady (Bundle extras)
```

Called when[CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession)has requested a postMessage channel through[requestPostMessageChannel(CustomTabsSessionToken, android.net.Uri)](https://developer.android.com/reference/android/support/customtabs/CustomTabsService#requestPostMessageChannel(android.support.customtabs.CustomTabsSessionToken, android.net.Uri))and the channel is ready for sending and receiving messages on both ends.

<br />

|                     Parameters                      ||
|----------|-------------------------------------------|
| `extras` | `Bundle`: Reserved for future use. <br /> |

### onNavigationEvent

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

```
void onNavigationEvent (int navigationEvent, 
                Bundle extras)
```

To be called when a navigation event happens.

<br />

|                                    Parameters                                    ||
|-------------------|---------------------------------------------------------------|
| `navigationEvent` | `int`: The code corresponding to the navigation event. <br /> |
| `extras`          | `Bundle`: Reserved for future use. <br />                     |

### onPostMessage

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

```
void onPostMessage (String message, 
                Bundle extras)
```

Called when a tab controlled by this[CustomTabsSession](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession)has sent a postMessage. If postMessage() is called from a single thread, then the messages will be posted in the same order. When received on the client side, it is the client's responsibility to preserve the ordering further.

<br />

|                      Parameters                      ||
|-----------|-------------------------------------------|
| `message` | `String`: The message sent. <br />        |
| `extras`  | `Bundle`: Reserved for future use. <br /> |

### onRelationshipValidationResult

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

```
void onRelationshipValidationResult (int relation, 
                Uri requestedOrigin, 
                boolean result, 
                Bundle extras)
```

Called when a relationship validation result is available.

<br />

|                                                                                                                                                                            Parameters                                                                                                                                                                            ||
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `relation`        | `int`: Relation for which the result is available. Value previously passed to[validateRelationship(int, Uri, Bundle)](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession#validateRelationship(int, android.net.Uri, android.os.Bundle)). Must be one of the`CustomTabsService#RELATION_* `constants. <br /> |
| `requestedOrigin` | `Uri`: Origin requested. Value previously passed to[validateRelationship(int, Uri, Bundle)](https://developer.android.com/reference/android/support/customtabs/CustomTabsSession#validateRelationship(int, android.net.Uri, android.os.Bundle)). <br />                                                                                       |
| `result`          | `boolean`: Whether the relation was validated. <br />                                                                                                                                                                                                                                                                                         |
| `extras`          | `Bundle`: Reserved for future use. <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)