# CustomTabsSessionToken

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

*** ** * ** ***


```
public class CustomTabsSessionToken
```

<br />

*** ** * ** ***

Wrapper class that can be used as a unique identifier for a session. Also contains an accessor for the `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback` for the session if there was any.

## Summary

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken#createMockSessionTokenForTesting()()` Provides browsers a way to generate a mock `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken` for testing purposes. |
| `boolean` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html o)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken#getCallback()()` |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken#getSessionTokenFromIntent(android.content.Intent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent)` Obtain a `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken` from an intent. |
| `int` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken#isAssociatedWith(androidx.browser.customtabs.CustomTabsSession)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession session)` |

## Public methods

### createMockSessionTokenForTesting

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

```
public static @NonNull CustomTabsSessionToken createMockSessionTokenForTesting()
```

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

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken` | A mock token with no functionality. |

### equals

```
public boolean equals(Object o)
```

### getCallback

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

```
public @Nullable CustomTabsCallback getCallback()
```

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback` | `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback` corresponding to this session if there was any non-null callbacks passed by the client. |

### getSessionTokenFromIntent

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

```
public static @Nullable CustomTabsSessionToken getSessionTokenFromIntent(@NonNull Intent intent)
```

Obtain a `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken` from an intent. See `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder` for ways to generate an intent for custom tabs.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent` | The intent to generate the token from. This has to include an extra for `https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent#EXTRA_SESSION()`. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSessionToken` | The token that was generated. |

### hashCode

```
public int hashCode()
```

### isAssociatedWith

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

```
public boolean isAssociatedWith(@NonNull CustomTabsSession session)
```

| Returns |
|---|---|
| `boolean` | Whether this token is associated with the given session. |