Stay organized with collections
Save and categorize content based on your preferences.
interface OnMediaKeyEventSessionChangedListener
Listener to receive changes in the media key event session, which would receive a media key event unless specified.
Summary
Public methods |
abstract Unit |
Called when the media key session is changed to the given media session.
|
Public methods
abstract fun onMediaKeyEventSessionChanged(
packageName: String,
sessionToken: MediaSession.Token?
): Unit
Called when the media key session is changed to the given media session. The key event session is the media session which would receive key event by default, unless the caller has specified the target.
The session token can be null
if the media button session is unset. In that case, packageName will return the package name of the last session's media button receiver, or an empty string if the last session didn't set a media button receiver.
Parameters |
packageName |
String: The package name of the component that will receive the media key event. Can be empty. This value cannot be null . |
sessionToken |
MediaSession.Token?: The media session's token. Can be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# MediaSessionManager.OnMediaKeyEventSessionChangedListener\n\nAdded in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnMediaKeyEventSessionChangedListener\n=====================================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/session/MediaSessionManager.OnMediaKeyEventSessionChangedListener \"View this page in Java\") \n\n```\ninterface OnMediaKeyEventSessionChangedListener\n```\n\n|--------------------------------------------------------------------------------------|\n| [android.media.session.MediaSessionManager.OnMediaKeyEventSessionChangedListener](#) |\n\nListener to receive changes in the media key event session, which would receive a media key event unless specified.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onMediaKeyEventSessionChanged](#onMediaKeyEventSessionChanged(kotlin.String,%20android.media.session.MediaSession.Token))`(`packageName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `sessionToken:` `[MediaSession.Token](/reference/kotlin/android/media/session/MediaSession.Token)?`)` Called when the media key session is changed to the given media session. |\n\nPublic methods\n--------------\n\n### onMediaKeyEventSessionChanged\n\nAdded in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onMediaKeyEventSessionChanged(\n packageName: String, \n sessionToken: MediaSession.Token?\n): Unit\n```\n\nCalled when the media key session is changed to the given media session. The key event session is the media session which would receive key event by default, unless the caller has specified the target.\n\nThe session token can be `null` if the media button session is unset. In that case, packageName will return the package name of the last session's media button receiver, or an empty string if the last session didn't set a media button receiver.\n\n| Parameters ||\n|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The package name of the component that will receive the media key event. Can be empty. This value cannot be `null`. |\n| `sessionToken` | [MediaSession.Token](/reference/kotlin/android/media/session/MediaSession.Token)?: The media session's token. Can be `null`. |"]]