# MediaNotification.ActionFactory

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/MediaNotification.java+class:androidx.media3.session.MediaNotification.ActionFactory)

*** ** * ** ***


```
@UnstableApi
interface MediaNotification.ActionFactory
```

<br />

*** ** * ** ***

Creates `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` and `https://developer.android.com/reference/android/app/PendingIntent.html` for notifications.

All methods will be called on the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getApplicationLooper()` of the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player` associated with the `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession` the notification is provided for.

## Summary

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.ActionFactory#createCustomAction(androidx.media3.session.MediaSession,androidx.core.graphics.drawable.IconCompat,java.lang.CharSequence,java.lang.String,android.os.Bundle)( mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!, icon: https://developer.android.com/reference/kotlin/androidx/core/graphics/drawable/IconCompat!, title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, customAction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, extras: https://developer.android.com/reference/android/os/Bundle.html! )` Creates a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` for a notification with a custom action. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.ActionFactory#createCustomActionFromCustomCommandButton(androidx.media3.session.MediaSession,androidx.media3.session.CommandButton)( mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!, customCommandButton: https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton! )` Creates a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` for a notification from a custom command button. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.ActionFactory#createMediaAction(androidx.media3.session.MediaSession,androidx.core.graphics.drawable.IconCompat,java.lang.CharSequence,int)( mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!, icon: https://developer.android.com/reference/kotlin/androidx/core/graphics/drawable/IconCompat!, title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, @https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` for a notification. |
| `https://developer.android.com/reference/android/app/PendingIntent.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.ActionFactory#createMediaActionPendingIntent(androidx.media3.session.MediaSession,int)( mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!, @https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a `https://developer.android.com/reference/android/app/PendingIntent.html` for a media action that will be handled by the library. |
| `https://developer.android.com/reference/android/app/PendingIntent.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.ActionFactory#createNotificationDismissalIntent(androidx.media3.session.MediaSession)(mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!)` Creates a `https://developer.android.com/reference/android/app/PendingIntent.html` triggered when the notification is dismissed. |

## Public functions

### createCustomAction

```
fun createCustomAction(
    mediaSession: MediaSession!,
    icon: IconCompat!,
    title: CharSequence!,
    customAction: String!,
    extras: Bundle!
): NotificationCompat.Action!
```

Creates a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` for a notification with a custom action. Actions created with this method are not expected to be handled by the library and will be forwarded to the `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.Provider#handleCustomCommand(androidx.media3.session.MediaSession,java.lang.String,android.os.Bundle)` that provided them.

| Parameters |
|---|---|
| `mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!` | The media session to which the action will be sent. |
| `icon: https://developer.android.com/reference/kotlin/androidx/core/graphics/drawable/IconCompat!` | The icon to show for this action. |
| `title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The title of the action. |
| `customAction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The custom action set. |
| `extras: https://developer.android.com/reference/android/os/Bundle.html!` | Extras to be included in the action. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.Provider#handleCustomCommand(androidx.media3.session.MediaSession,java.lang.String,android.os.Bundle)` |   |

### createCustomActionFromCustomCommandButton

```
fun createCustomActionFromCustomCommandButton(
    mediaSession: MediaSession!,
    customCommandButton: CommandButton!
): NotificationCompat.Action!
```

Creates a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` for a notification from a custom command button. Actions created with this method are not expected to be handled by the library and will be forwarded to the `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.Provider#handleCustomCommand(androidx.media3.session.MediaSession,java.lang.String,android.os.Bundle)` that provided them.

The returned `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` will have a `https://developer.android.com/reference/android/app/PendingIntent.html` with the extras from `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommand#customExtras()`. Accordingly, the `https://developer.android.com/reference/kotlin/androidx/media3/session/SessionCommand#customExtras()` will be passed to `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.Provider#handleCustomCommand(androidx.media3.session.MediaSession,java.lang.String,android.os.Bundle)` when the action is executed.

| Parameters |
|---|---|
| `mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!` | The media session to which the action will be sent. |
| `customCommandButton: https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton!` | A `https://developer.android.com/reference/kotlin/androidx/media3/session/CommandButton`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/session/MediaNotification.Provider#handleCustomCommand(androidx.media3.session.MediaSession,java.lang.String,android.os.Bundle)` |   |

### createMediaAction

```
fun createMediaAction(
    mediaSession: MediaSession!,
    icon: IconCompat!,
    title: CharSequence!,
    @Player.Command command: Int
): NotificationCompat.Action!
```

Creates a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` for a notification. These actions will be handled by the library.

| Parameters |
|---|---|
| `mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!` | The media session to which the action will be sent. |
| `icon: https://developer.android.com/reference/kotlin/androidx/core/graphics/drawable/IconCompat!` | The icon to show for this action. |
| `title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The title of the action. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A command to send when users trigger this action. |

### createMediaActionPendingIntent

```
fun createMediaActionPendingIntent(
    mediaSession: MediaSession!,
    @Player.Command command: Int
): PendingIntent!
```

Creates a `https://developer.android.com/reference/android/app/PendingIntent.html` for a media action that will be handled by the library.

| Parameters |
|---|---|
| `mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!` | The media session to which the action will be sent. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command command: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.html!` | The `https://developer.android.com/reference/android/app/PendingIntent.html`. |

### createNotificationDismissalIntent

```
fun createNotificationDismissalIntent(mediaSession: MediaSession!): PendingIntent!
```

Creates a `https://developer.android.com/reference/android/app/PendingIntent.html` triggered when the notification is dismissed.

| Parameters |
|---|---|
| `mediaSession: https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession!` | The media session for which the intent is created. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.html!` | The `https://developer.android.com/reference/android/app/PendingIntent.html`. |