# PlayerNotificationManager.NotificationListener

# PlayerNotificationManager.NotificationListener

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/ui/PlayerNotificationManager.NotificationListener "View this page in Java")

<br />

```
interface PlayerNotificationManager.NotificationListener
```

<br />

*** ** * ** ***

A listener for changes to the notification.

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onNotificationCancelled](https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.NotificationListener#onNotificationCancelled(int,boolean))`(notificationId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, dismissedByUser: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Called after the notification has been cancelled.                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onNotificationPosted](https://developer.android.com/reference/kotlin/androidx/media3/ui/PlayerNotificationManager.NotificationListener#onNotificationPosted(int,android.app.Notification,boolean))`(` ` notificationId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` notification: `[Notification](https://developer.android.com/reference/android/app/Notification.html)`!,` ` ongoing: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) `)` Called each time after the notification has been posted. |

## Public functions

### onNotificationCancelled

```
fun onNotificationCancelled(notificationId: Int, dismissedByUser: Boolean): Unit
```

Called after the notification has been cancelled.  

|                                               Parameters                                               |
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| `notificationId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | The id of the notification which has been cancelled.                                |
| `dismissedByUser: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if the notification is cancelled because the user dismissed the notification. |

### onNotificationPosted

```
fun onNotificationPosted(
    notificationId: Int,
    notification: Notification!,
    ongoing: Boolean
): Unit
```

Called each time after the notification has been posted.

For a service, the`ongoing`flag can be used as an indicator as to whether it should be in the foreground.  

|                                                Parameters                                                |
|----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| `notificationId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)            | The id of the notification which has been posted.                                         |
| `notification: `[Notification](https://developer.android.com/reference/android/app/Notification.html)`!` | The[Notification](https://developer.android.com/reference/android/app/Notification.html). |
| `ongoing: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)           | Whether the notification is ongoing.                                                      |