# 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
public interface MediaNotification.ActionFactory
```

<br />

*** ** * ** ***

Creates `https://developer.android.com/reference/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/androidx/media3/common/Player#getApplicationLooper()` of the `https://developer.android.com/reference/androidx/media3/common/Player` associated with the `https://developer.android.com/reference/androidx/media3/session/MediaSession` the notification is provided for.

## Summary

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

## Public methods

### createCustomAction

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

Creates a `https://developer.android.com/reference/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/androidx/media3/session/MediaNotification.Provider#handleCustomCommand(androidx.media3.session.MediaSession,java.lang.String,android.os.Bundle)` that provided them.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaSession mediaSession` | The media session to which the action will be sent. |
| `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat icon` | The icon to show for this action. |
| `https://developer.android.com/reference/java/lang/CharSequence.html title` | The title of the action. |
| `https://developer.android.com/reference/java/lang/String.html customAction` | The custom action set. |
| `https://developer.android.com/reference/android/os/Bundle.html extras` | Extras to be included in the action. |

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

### createCustomActionFromCustomCommandButton

```
abstract NotificationCompat.Action createCustomActionFromCustomCommandButton(
    MediaSession mediaSession,
    CommandButton customCommandButton
)
```

Creates a `https://developer.android.com/reference/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/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/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/androidx/media3/session/SessionCommand#customExtras()`. Accordingly, the `https://developer.android.com/reference/androidx/media3/session/SessionCommand#customExtras()` will be passed to `https://developer.android.com/reference/androidx/media3/session/MediaNotification.Provider#handleCustomCommand(androidx.media3.session.MediaSession,java.lang.String,android.os.Bundle)` when the action is executed.

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

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

### createMediaAction

```
abstract NotificationCompat.Action createMediaAction(
    MediaSession mediaSession,
    IconCompat icon,
    CharSequence title,
    @Player.Command int command
)
```

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

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

### createMediaActionPendingIntent

```
abstract PendingIntent createMediaActionPendingIntent(
    MediaSession mediaSession,
    @Player.Command int command
)
```

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaSession mediaSession` | The media session to which the action will be sent. |
| `@https://developer.android.com/reference/androidx/media3/common/Player.Command int command` | The `https://developer.android.com/reference/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

```
default PendingIntent createNotificationDismissalIntent(MediaSession mediaSession)
```

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaSession 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`. |