# PlaybackState.CustomAction.Builder

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/media/session/PlaybackState.CustomAction.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                       ||
| ↳ | [android.media.session.PlaybackState.CustomAction.Builder](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction.Builder#) |

Builder for[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction)objects.

## Summary

|                                                                                                                                                                                                                                                                                                                 Public constructors                                                                                                                                                                                                                                                                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction.Builder#Builder(kotlin.String,%20kotlin.CharSequence,%20kotlin.Int))`(`action:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `name:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`, `icon:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Creates a[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction)builder with the id, name, and icon set. |

|                                                                                                                                                                                                                                                                 Public methods                                                                                                                                                                                                                                                                  ||
|-------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [PlaybackState.CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction)!                  | [build](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction.Builder#build())`()` Build and return the[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction)instance with the specified values.                                                                                            |
| [PlaybackState.CustomAction.Builder](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction.Builder#)! | [setExtras](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction.Builder#setExtras(android.os.Bundle))`(`extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` Set optional extras for the[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction). |

## Public constructors

### Builder

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(
    action: String!, 
    name: CharSequence!, 
    icon: Int)
```

Creates a[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction)builder with the id, name, and icon set.

|                                                                                                                                                                                                                        Parameters                                                                                                                                                                                                                         ||
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `action` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The action of the[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction).                                                                                                                                                                                                                             |
| `name`   | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!:The display name of the[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction). This name will be displayed along side the action if the UI supports it.                                                                                                                                 |
| `icon`   | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The icon resource id of the[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction). This resource id must be in the same package as the[MediaSession](https://developer.android.com/reference/kotlin/android/media/session/MediaSession). It will be displayed with the custom action if the UI supports it. |

## Public methods

### build

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): PlaybackState.CustomAction!
```

Build and return the[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction)instance with the specified values.

|                                                                                                                            Return                                                                                                                             ||
|--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
| [PlaybackState.CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction)! | A new[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction)instance. |

### setExtras

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setExtras(extras: Bundle!): PlaybackState.CustomAction.Builder!
```

Set optional extras for the[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction). These extras are meant to be consumed by a[MediaController](https://developer.android.com/reference/kotlin/android/media/session/MediaController)if it knows how to handle them. Keys should be fully qualified (e.g. "com.example.MY_ARG") to avoid collisions.

|                                                                                                             Parameters                                                                                                              ||
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `extras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!:Optional extras for the[CustomAction](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction). |

|                                                                         Return                                                                         ||
|-------------------------------------------------------------------------------------------------------------------------------------------------|-------|
| [PlaybackState.CustomAction.Builder](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState.CustomAction.Builder#)! | this. |