# MediaSessionService.Listener

# MediaSessionService.Listener

Artifact:[androidx.media3:media3-session](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/session/MediaSessionService.java+class:androidx.media3.session.MediaSessionService.Listener)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/session/MediaSessionService.Listener "View this page in Java")

<br />

```
@UnstableApi
interface MediaSessionService.Listener
```

<br />

*** ** * ** ***

Listener for[MediaSessionService](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSessionService).

The methods will be called on the main thread.

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | `@`[RequiresApi](https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi)`(value = 31)` [onForegroundServiceStartNotAllowedException](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSessionService.Listener#onForegroundServiceStartNotAllowedException())`()` Called when the service fails to start in the foreground and a[ForegroundServiceStartNotAllowedException](https://developer.android.com/reference/android/app/ForegroundServiceStartNotAllowedException.html)is thrown on Android 12 or later. |

## Public functions

### onForegroundServiceStartNotAllowedException

```
@RequiresApi(value = 31)
fun onForegroundServiceStartNotAllowedException(): Unit
```

Called when the service fails to start in the foreground and a[ForegroundServiceStartNotAllowedException](https://developer.android.com/reference/android/app/ForegroundServiceStartNotAllowedException.html)is thrown on Android 12 or later.