Cast.Listener
Stay organized with collections
Save and categorize content based on your preferences.
The list of Cast
callbacks. These
callbacks may get called at any time, when connected to a Google Cast device.
Public Constructor Summary
Public Method Summary
void |
|
void |
onApplicationDisconnected
(int statusCode) Called when the connection to the receiver application has been lost, such as
when another client has launched a new application.
|
void |
|
void |
|
void |
|
void |
|
void |
onVolumeChanged
() Called when the device's volume or mute state has changed.
|
Inherited Method Summary
From class java.lang.Object
Public Methods
Called when the active-input state of the device has changed.
public void
onApplicationDisconnected
(int
statusCode)
Called when the connection to the receiver application has been lost, such as when
another client has launched a new application.
Parameters
statusCode
A status code indicating the reason for the disconnect. One of the error
constants defined in CastStatusCodes
.
Called when the application metadata of the currently running receiver application
has changed. This will happen whenever a receiver application launches or
terminates.
Parameters
applicationMetadata
The new application metadata. May be null
if no application is
currently running.
public void
onApplicationStatusChanged
()
Called when the status of the connected application has changed.
public void
onDeviceNameChanged
()
Called when the device's name has changed.
public void
onStandbyStateChanged
(int
standbyState)
Called when the standby state of the device has changed.
public void
onVolumeChanged
()
Called when the device's volume or mute state has changed.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eCast.Listener\u003c/code\u003e provides callbacks for monitoring the status and events of a Google Cast device.\u003c/p\u003e\n"],["\u003cp\u003eIt includes callbacks for application connections, metadata changes, device status updates, and volume changes.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can implement these callbacks to react to changes and update their application's UI or behavior accordingly.\u003c/p\u003e\n"],["\u003cp\u003eThe callbacks provide information like active input state, application status, device name, standby state, and volume level.\u003c/p\u003e\n"],["\u003cp\u003eThese callbacks are crucial for building interactive and responsive Google Cast experiences within Android applications.\u003c/p\u003e\n"]]],["The `Cast.Listener` class provides callbacks for monitoring Google Cast device states. Key actions include `onActiveInputStateChanged`, signaling changes in device input; `onApplicationDisconnected`, indicating a loss of connection to the receiver app; `onApplicationMetadataChanged`, reporting updates to the receiver app's metadata; `onApplicationStatusChanged`, reflecting the connected app's status; `onDeviceNameChanged` when the device name updates; `onStandbyStateChanged`, representing device standby status changes; and `onVolumeChanged`, reporting volume or mute state modifications.\n"],null,["# Cast.Listener\n\npublic static class **Cast.Listener** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nThe list of [Cast](/android/reference/com/google/android/gms/cast/Cast) callbacks. These\ncallbacks may get called at any time, when connected to a Google Cast device. \n\n### Public Constructor Summary\n\n|---|---------------------------------------------------------------------------------------|\n| | [Listener](/android/reference/com/google/android/gms/cast/Cast.Listener#Listener())() |\n\n### Public Method Summary\n\n|------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [onActiveInputStateChanged](/android/reference/com/google/android/gms/cast/Cast.Listener#onActiveInputStateChanged(int))(int activeInputState) Called when the active-input state of the device has changed. |\n| void | [onApplicationDisconnected](/android/reference/com/google/android/gms/cast/Cast.Listener#onApplicationDisconnected(int))(int statusCode) Called when the connection to the receiver application has been lost, such as when another client has launched a new application. |\n| void | [onApplicationMetadataChanged](/android/reference/com/google/android/gms/cast/Cast.Listener#onApplicationMetadataChanged(com.google.android.gms.cast.ApplicationMetadata))([ApplicationMetadata](/android/reference/com/google/android/gms/cast/ApplicationMetadata) applicationMetadata) Called when the application metadata of the currently running receiver application has changed. |\n| void | [onApplicationStatusChanged](/android/reference/com/google/android/gms/cast/Cast.Listener#onApplicationStatusChanged())() Called when the status of the connected application has changed. |\n| void | [onDeviceNameChanged](/android/reference/com/google/android/gms/cast/Cast.Listener#onDeviceNameChanged())() Called when the device's name has changed. |\n| void | [onStandbyStateChanged](/android/reference/com/google/android/gms/cast/Cast.Listener#onStandbyStateChanged(int))(int standbyState) Called when the standby state of the device has changed. |\n| void | [onVolumeChanged](/android/reference/com/google/android/gms/cast/Cast.Listener#onVolumeChanged())() Called when the device's volume or mute state has changed. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public **Listener** ()\n\nPublic Methods\n--------------\n\n#### public void **onActiveInputStateChanged** (int activeInputState)\n\nCalled when the active-input state of the device has changed. \n\n##### Parameters\n\n| activeInputState | The new active-input state. One of the constants [Cast.ACTIVE_INPUT_STATE_UNKNOWN](/android/reference/com/google/android/gms/cast/Cast#ACTIVE_INPUT_STATE_UNKNOWN), [Cast.ACTIVE_INPUT_STATE_NO](/android/reference/com/google/android/gms/cast/Cast#ACTIVE_INPUT_STATE_NO), [Cast.ACTIVE_INPUT_STATE_YES](/android/reference/com/google/android/gms/cast/Cast#ACTIVE_INPUT_STATE_YES). |\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n#### public void **onApplicationDisconnected** (int statusCode)\n\nCalled when the connection to the receiver application has been lost, such as when\nanother client has launched a new application. \n\n##### Parameters\n\n| statusCode | A status code indicating the reason for the disconnect. One of the error constants defined in [CastStatusCodes](/android/reference/com/google/android/gms/cast/CastStatusCodes). |\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n#### public void **onApplicationMetadataChanged** ([ApplicationMetadata](/android/reference/com/google/android/gms/cast/ApplicationMetadata) applicationMetadata)\n\nCalled when the application metadata of the currently running receiver application\nhas changed. This will happen whenever a receiver application launches or\nterminates. \n\n##### Parameters\n\n| applicationMetadata | The new application metadata. May be `null` if no application is currently running. |\n|---------------------|-------------------------------------------------------------------------------------|\n\n#### public void **onApplicationStatusChanged** ()\n\nCalled when the status of the connected application has changed. \n\n#### public void **onDeviceNameChanged** ()\n\nCalled when the device's name has changed. \n\n#### public void **onStandbyStateChanged** (int standbyState)\n\nCalled when the standby state of the device has changed. \n\n##### Parameters\n\n| standbyState | The new standby state. One of the constants [Cast.STANDBY_STATE_UNKNOWN](/android/reference/com/google/android/gms/cast/Cast#STANDBY_STATE_UNKNOWN), [Cast.STANDBY_STATE_NO](/android/reference/com/google/android/gms/cast/Cast#STANDBY_STATE_NO), or [Cast.STANDBY_STATE_YES](/android/reference/com/google/android/gms/cast/Cast#STANDBY_STATE_YES). |\n|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n#### public void **onVolumeChanged** ()\n\nCalled when the device's volume or mute state has changed."]]