public class **CastContext** extends [Object](https://developer.android.com/reference/java/lang/Object.html)  
A singleton class containing global context for the Cast SDK. The shared instance can be
accessed by calling `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getSharedInstance(android.content.Context)`. To properly initialize `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`,
the application must have a class that implements `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/OptionsProvider`
interface:

```
     package com.example.app;

     public class CastOptionsProvider implements OptionsProvider {
         @Override
         public CastOptions getCastOptions(Context appContext) {
             ...
         }
     }
 
```
and specify its fully qualified class name in the `AndroidManifest.xml` with the key `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#OPTIONS_PROVIDER_CLASS_NAME_KEY`:

```
     ...
     <meta-data
         android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
         android:value="com.example.app.CastOptionsProvider" />
     ...
 
```
All public methods must be called from the main thread.

### Constant Summary

|---|---|---|
| [String](https://developer.android.com/reference/java/lang/String.html) | [OPTIONS_PROVIDER_CLASS_NAME_KEY](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#OPTIONS_PROVIDER_CLASS_NAME_KEY) | The metadata key to specify the fully qualified name of the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/OptionsProvider` implementation in the `AndroidManifest.xml`. |

### Public Method Summary

|---|---|
| void | [addAppVisibilityListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#addAppVisibilityListener(com.google.android.gms.cast.framework.AppVisibilityListener))([AppVisibilityListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/AppVisibilityListener) listener) *This method is deprecated. Don't use the SDK to listen to app visibility changes. Use alternative ways for watching activity lifecycle changes such as by overriding `https://developer.android.com/reference/android/app/Activity.html` lifecycle change methods, or by using `https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html`. This deprecated method is now a no-op and will be removed in the next version.* |
| void | [addCastStateListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#addCastStateListener(com.google.android.gms.cast.framework.CastStateListener))([CastStateListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastStateListener) listener) Adds a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastStateListener` to monitor changes of the current `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastState`. |
| void | [addSessionTransferCallback](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#addSessionTransferCallback(com.google.android.gms.cast.framework.SessionTransferCallback))([SessionTransferCallback](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback) callback) Adds a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback` to monitor the transfer between different endpoints. |
| [CastOptions](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions) | [getCastOptions](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getCastOptions())() Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions`. |
| int | [getCastReasonCodeForCastStatusCode](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getCastReasonCodeForCastStatusCode(int))(int castStatusCode) Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastReasonCodes` for the given `https://developers.google.com/android/reference/com/google/android/gms/cast/CastStatusCodes`. |
| int | [getCastState](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getCastState())() Returns the current `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastState`. |
| [MediaNotificationManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/MediaNotificationManager) | [getMediaNotificationManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getMediaNotificationManager())() Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/MediaNotificationManager`. |
| MediaRouteSelector | [getMergedSelector](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getMergedSelector())() Returns the merged `https://developers.google.com/android/reference/androidx/mediarouter/media/MediaRouteSelector` used for discovering devices and deciding whether to show the MediaRouteButton. |
| [PrecacheManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/PrecacheManager) | [getPrecacheManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getPrecacheManager())() *This method is deprecated. The Precache functionality is removed.* |
| [SessionManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionManager) | [getSessionManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getSessionManager())() Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionManager`, never returns `null`. |
| static [CastContext](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext) | [getSharedInstance](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getSharedInstance(android.content.Context))([Context](https://developer.android.com/reference/android/content/Context.html) context) Returns a shared instance of `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`. |
| static [CastContext](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext) | [getSharedInstance](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getSharedInstance())() Returns the shared instance of `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`. |
| static Task\<[CastContext](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext)\> | [getSharedInstance](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getSharedInstance(android.content.Context,%20java.util.concurrent.Executor))([Context](https://developer.android.com/reference/android/content/Context.html) context, [Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html) executor) Returns an asynchronous [Task API](https://developers.google.com/android/guides/tasks) call on the shared instance of `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`, which will not block the caller thread. |
| boolean | [isAppVisible](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#isAppVisible())() *This method is deprecated. Don't use the SDK to listen to app visibility changes. Use alternative ways for watching activity lifecycle changes such as by overriding `https://developer.android.com/reference/android/app/Activity.html` lifecycle change methods, or by using `https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html`. This deprecated method always return false now and will be removed in the next version.* |
| boolean | [onDispatchVolumeKeyEventBeforeJellyBean](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#onDispatchVolumeKeyEventBeforeJellyBean(android.view.KeyEvent))([KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html) event) *This method is deprecated. Google Play services discontinued updates for Jelly Bean (API levels 16, 17 \& 18) since July 2021. This method always returns false and will be removed in the next release.* |
| void | [removeAppVisibilityListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#removeAppVisibilityListener(com.google.android.gms.cast.framework.AppVisibilityListener))([AppVisibilityListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/AppVisibilityListener) listener) *This method is deprecated. Don't use the SDK to listen to app visibility changes. Use alternative ways for watching activity lifecycle changes such as by overriding `https://developer.android.com/reference/android/app/Activity.html` lifecycle change methods, or by using `https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html`. This deprecated method is now a no-op and will be removed in the next version.* |
| void | [removeCastStateListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#removeCastStateListener(com.google.android.gms.cast.framework.CastStateListener))([CastStateListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastStateListener) listener) Removes a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastStateListener`. |
| void | [removeSessionTransferCallback](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#removeSessionTransferCallback(com.google.android.gms.cast.framework.SessionTransferCallback))([SessionTransferCallback](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback) callback) Removes a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback` from monitoring endpoint transferring events. |
| void | [setLaunchCredentialsData](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#setLaunchCredentialsData(com.google.android.gms.cast.CredentialsData))(CredentialsData credentialsData) Sets the credentials data of the current user. |
| void | [setReceiverApplicationId](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#setReceiverApplicationId(java.lang.String))([String](https://developer.android.com/reference/java/lang/String.html) applicationId) Sets the receiver application ID. |
| void | [setShowSystemOutputSwitcherOnCastIconClick](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#setShowSystemOutputSwitcherOnCastIconClick(boolean))(boolean showOutputSwitcherOnCastIconClick) Dynamically overrides any value set in `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions.Builder#setShowSystemOutputSwitcherOnCastIconClick(boolean)`. |

### Inherited Method Summary

From class java.lang.Object

|---|---|
| [Object](https://developer.android.com/reference/java/lang/Object.html) | clone() |
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| void | finalize() |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Constants

#### public static final [String](https://developer.android.com/reference/java/lang/String.html)
**OPTIONS_PROVIDER_CLASS_NAME_KEY**

The metadata key to specify the fully qualified name of the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/OptionsProvider`
implementation in the `AndroidManifest.xml`.
Constant Value: "com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"

## Public Methods

#### public void **addAppVisibilityListener** ([AppVisibilityListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/AppVisibilityListener) listener)

**This method is deprecated.**   

Don't use the SDK to listen to app visibility changes. Use alternative ways for watching
activity lifecycle changes such as by overriding `https://developer.android.com/reference/android/app/Activity.html`
lifecycle change methods, or by using `https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html`. This deprecated method is now a no-op
and will be removed in the next version.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) |   |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException.html) |   |
|---|---|

#### public void **addCastStateListener** ([CastStateListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastStateListener) listener)

Adds a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastStateListener`
to monitor changes of the current `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastState`.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException.html) | If listener is `null`. |
|---|---|

#### public void **addSessionTransferCallback** ([SessionTransferCallback](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback) callback)

Adds a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback` to monitor the transfer between different
endpoints.

##### Parameters

| callback | a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback` to monitor endpoint transferring |
|---|---|

#### public [CastOptions](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions)
**getCastOptions** ()

Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions`.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
|---|---|

#### public int **getCastReasonCodeForCastStatusCode** (int castStatusCode)

Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastReasonCodes`
for the given `https://developers.google.com/android/reference/com/google/android/gms/cast/CastStatusCodes`.

Some of the `https://developers.google.com/android/reference/com/google/android/gms/cast/CastStatusCodes`
are used by Cast SDK internally. This method translates those `https://developers.google.com/android/reference/com/google/android/gms/cast/CastStatusCodes`
to `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastReasonCodes`
which is developer-friendly.

##### Parameters

| castStatusCode | the `https://developers.google.com/android/reference/com/google/android/gms/cast/CastStatusCodes` for checking the detailed explanation |
|---|---|

#### public int **getCastState** ()

Returns the current `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastState`.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
|---|---|

#### public [MediaNotificationManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/MediaNotificationManager)
**getMediaNotificationManager** ()

Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/MediaNotificationManager`.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
|---|---|

#### public MediaRouteSelector
**getMergedSelector** ()

Returns the merged `https://developers.google.com/android/reference/androidx/mediarouter/media/MediaRouteSelector`
used for discovering devices and deciding whether to show the MediaRouteButton. This
selector is merged with any additional `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionProvider`s
that might be registered with the CastContext.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
|---|---|

#### public [PrecacheManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/PrecacheManager)
**getPrecacheManager** ()

**This method is deprecated.**   

The Precache functionality is removed.
Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/PrecacheManager`.

#### public [SessionManager](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionManager)
**getSessionManager** ()

Returns the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionManager`,
never returns `null`.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
|---|---|

#### public static [CastContext](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext)
**getSharedInstance** ([Context](https://developer.android.com/reference/android/content/Context.html) context)

Returns a shared instance of `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`.
The shared instance will be initialized on the first time this method is called.

##### Parameters

| context | An application `https://developer.android.com/reference/android/content/Context.html`. If this is not an application `https://developer.android.com/reference/android/content/Context.html`, `https://developer.android.com/reference/android/content/Context.html#getApplicationContext()` will be called on the given context, to retrieve it. |
|---|---|

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If any of the following: - This method is not called on the main thread. - The fully qualified name of the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/OptionsProvider` implementation is not specified as a metadata in the `AndroidManifest.xml` with key `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#OPTIONS_PROVIDER_CLASS_NAME_KEY`. - `optionsProviderClass` or its nullary constructor is not accessible. - Instantiation of `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/OptionsProvider` fails for some other reason. |
|---|---|

#### public static [CastContext](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext)
**getSharedInstance** ()

Returns the shared instance of `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`.
This method must be called after `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`
is initialized through `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getSharedInstance(android.content.Context,%20java.util.concurrent.Executor)`. Otherwise, this method will return
`null`.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
|---|---|

#### public static Task\<[CastContext](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext)\>
**getSharedInstance** ([Context](https://developer.android.com/reference/android/content/Context.html) context, [Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html) executor)

Returns an asynchronous [Task
API](https://developers.google.com/android/guides/tasks) call on the shared instance of `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`,
which will not block the caller thread. The shared instance will be initialized on the
first time this method is called.

Note that `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getSharedInstance(android.content.Context,%20java.util.concurrent.Executor)` should be called in the `https://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)` method of the activities that might display a Cast
button. The Cast SDK provides `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastButtonFactory`
to set up a Cast button.

Note that other activity methods, for example `https://developer.android.com/reference/android/app/Activity.html#onResume()`,
need to check the availability of the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`
object before using it, because the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext`
is initialized on the `https://developer.android.com/reference/java/util/concurrent/Executor.html`.

Note that `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/ModuleUnavailableException` could be thrown when the SDK fails to load the
internal Cast module. The caller will get the exception from `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task#getException()`
when the task completes.

##### Parameters

| context | An application `https://developer.android.com/reference/android/content/Context.html`. If this is not an application `https://developer.android.com/reference/android/content/Context.html`, `https://developer.android.com/reference/android/content/Context.html#getApplicationContext()` will be called on the given context, to retrieve it. |
| executor | An `https://developer.android.com/reference/java/util/concurrent/Executor.html` to load the internal Cast module. |
|---|---|

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If any of the following: - This method is not called on the main thread. - The fully qualified name of the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/OptionsProvider` implementation is not specified as a metadata in the `AndroidManifest.xml` with key `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#OPTIONS_PROVIDER_CLASS_NAME_KEY`. - `optionsProviderClass` or its nullary constructor is not accessible. - Instantiation of `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/OptionsProvider` fails for some other reason. |
|---|---|

#### public boolean **isAppVisible** ()

**This method is deprecated.**   

Don't use the SDK to listen to app visibility changes. Use alternative ways for watching
activity lifecycle changes such as by overriding `https://developer.android.com/reference/android/app/Activity.html`
lifecycle change methods, or by using `https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html`. This deprecated method always return
false now and will be removed in the next version.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) |   |
|---|---|

#### public boolean **onDispatchVolumeKeyEventBeforeJellyBean** ([KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html) event)

**This method is deprecated.**   

Google Play services discontinued updates for Jelly Bean (API levels 16, 17 \& 18) since
July 2021. This method always returns false and will be removed in the next release.
If your application supports SDK versions before JELLY BEAN, you should call this
method to delegate the handling of physical volume key events to the SDK so that users
can use the physical volume keys to control device volume of the Cast receiver. Clients
should override `https://developer.android.com/reference/android/app/Activity.html#dispatchKeyEvent(android.view.KeyEvent)` and call this method:

```
     @Override
     public boolean dispatchKeyEvent(KeyEvent event) {
         return CastContext.getSharedInstance().onDispatchVolumeKeyEventBeforeJellyBean(event)
                 || super.dispatchKeyEvent(event);
     }
 
```
The amount of volume delta to increase or decrease is set through `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions.Builder#setVolumeDeltaBeforeIceCreamSandwich(double)`. This method is a no-op on platform JELLY BEAN and above.

##### Parameters

| event | the dispatched event |
|---|---|

#### public void **removeAppVisibilityListener** ([AppVisibilityListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/AppVisibilityListener) listener)

**This method is deprecated.**   

Don't use the SDK to listen to app visibility changes. Use alternative ways for watching
activity lifecycle changes such as by overriding `https://developer.android.com/reference/android/app/Activity.html`
lifecycle change methods, or by using `https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html`. This deprecated method is now a no-op
and will be removed in the next version.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) |   |
|---|---|

#### public void **removeCastStateListener** ([CastStateListener](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastStateListener) listener)

Removes a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastStateListener`.

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
|---|---|

#### public void **removeSessionTransferCallback** ([SessionTransferCallback](https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback) callback)

Removes a `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback` from monitoring endpoint transferring events.

##### Parameters

| callback | the `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/SessionTransferCallback` to be unregistered |
|---|---|

#### public void **setLaunchCredentialsData** (CredentialsData credentialsData)

Sets the credentials data of the current user. You should call this API with the
current user information right after `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastContext#getSharedInstance()` and whenever user account is changed.

Currently it serves two purposes:

- The credentials data will be embedded in the launch request. If it is to launch an Android TV app, the app can use the credentials data to determine if the app supports this specific user. If not, the cast app will be launched instead.
- If an Android TV app is launched, the credential data will be passed to the app, within the launch intent. The app can use this data to personalize the user experience.

#### public void **setReceiverApplicationId** ([String](https://developer.android.com/reference/java/lang/String.html) applicationId)

Sets the receiver application ID. This overrides the receiver application ID
specified in `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions`.

Calling this method will result in the receiver application ID used for discovery
and application launch being changed. The Cast button status will also changed
accordingly. If the new application ID is different than the current one, the current
session will be ended if there is any.

Specifying null or an empty string indicates that the app does not want to discover
receiver devices or launch a receiver application.

For discovering for multiple application IDs at the same time, or for discovering
for other application ID without affect the current session, use `https://developers.google.com/android/reference/androidx/mediarouter/media/MediaRouter`
APIs instead.

##### Parameters

| applicationId | The receiver application ID that will be used to discover the receiver device and launch the receiver application. |
|---|---|

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If this method is not called on the main thread. |
|---|---|

#### public void **setShowSystemOutputSwitcherOnCastIconClick** (boolean showOutputSwitcherOnCastIconClick)

Dynamically overrides any value set in `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions.Builder#setShowSystemOutputSwitcherOnCastIconClick(boolean)`.

Note that the system output switcher is only shown when it is supported by the
Android system. If the Android system cannot provide a system output switcher at the
time of the request, the application will automatically fall back to the standard
in-app MediaRouter device picker UI.

Make sure to see the documentation for `https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions.Builder#setShowSystemOutputSwitcherOnCastIconClick(boolean)` for
steps you must take to properly integrate with the output switcher.

##### Parameters

| showOutputSwitcherOnCastIconClick | `true` if the system output switcher should be shown when the cast icon is clicked on Android T+ (SDK 33 and above). |
|---|---|