> Documentation index: https://developer.android.com/reference/llms.txt

# MediaSession.ConnectionResult.AcceptedResultBuilder

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

*** ** * ** ***


```
@UnstableApi
class MediaSession.ConnectionResult.AcceptedResultBuilder
```

<br />

*** ** * ** ***

A builder for `ConnectionResult` instances to accept a connection.

## Summary

| ### Public constructors |
|---|
| `AcceptedResultBuilder()` Creates an instance to configure the result of an accepted connection from a controller. |
| `[AcceptedResultBuilder](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession.ConnectionResult.AcceptedResultBuilder#AcceptedResultBuilder(androidx.media3.session.MediaSession))(mediaSession: MediaSession!)` **This function is deprecated.** Use `AcceptedResultBuilder` instead to start with defaults for the given session and controller, or use `AcceptedResultBuilder` to initialize the builder with empty commands. <br /> |
| `AcceptedResultBuilder( mediaSession: MediaSession!, controllerInfo: MediaSession.ControllerInfo! )` Creates an instance to configure the result of an accepted connection from a controller with the default available commands given the provided `MediaSession` and `ControllerInfo`. |

| ### Public functions |
|---|---|
| `MediaSession.ConnectionResult!` | `build()` Returns a new `ConnectionResult` instance for accepting a connection. |
| `MediaSession.ConnectionResult.AcceptedResultBuilder!` | `@CanIgnoreReturnValue setAvailablePlayerCommands(availablePlayerCommands: Player.Commands!)` Sets the player commands that are available to the controller that gets this result returned when `connecting`. |
| `MediaSession.ConnectionResult.AcceptedResultBuilder!` | `@CanIgnoreReturnValue setAvailableSessionCommands(availableSessionCommands: SessionCommands!)` Sets the session commands that are available to the controller that gets this result returned when `connecting`. |
| `MediaSession.ConnectionResult.AcceptedResultBuilder!` | `@CanIgnoreReturnValue [setCustomLayout](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession.ConnectionResult.AcceptedResultBuilder#setCustomLayout(java.util.List<androidx.media3.session.CommandButton>))(customLayout: (Mutable)List<CommandButton!>?)` **This function is deprecated.** Use `setMediaButtonPreferences` instead. <br /> |
| `MediaSession.ConnectionResult.AcceptedResultBuilder!` | `@CanIgnoreReturnValue setMediaButtonPreferences( mediaButtonPreferences: (Mutable)List<CommandButton!>? )` Sets the media button preferences, overriding the ` media button preferences of the session`. |
| `MediaSession.ConnectionResult.AcceptedResultBuilder!` | `@CanIgnoreReturnValue setSessionActivity(sessionActivity: PendingIntent?)` Sets the session activity, overriding the `session activity of the session`. |
| `MediaSession.ConnectionResult.AcceptedResultBuilder!` | `@CanIgnoreReturnValue setSessionExtras(sessionExtras: Bundle!)` Sets the session extras, overriding the `extras of the session`. |

## Public constructors

### AcceptedResultBuilder

```
AcceptedResultBuilder()
```

Creates an instance to configure the result of an accepted connection from a controller.

The available `SessionCommands` and `Player.Commands` default to empty and need to be configured.

### AcceptedResultBuilder

```
[AcceptedResultBuilder](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession.ConnectionResult.AcceptedResultBuilder#AcceptedResultBuilder(androidx.media3.session.MediaSession))(mediaSession: MediaSession!)
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `AcceptedResultBuilder` instead to start with defaults for the given session and controller, or use `AcceptedResultBuilder` to initialize the builder with empty commands.

### AcceptedResultBuilder

```
AcceptedResultBuilder(
    mediaSession: MediaSession!,
    controllerInfo: MediaSession.ControllerInfo!
)
```

Creates an instance to configure the result of an accepted connection from a controller with the default available commands given the provided `MediaSession` and `ControllerInfo`.

If the controller is `trusted`, the `DEFAULT_PLAYER_COMMANDS` and either `DEFAULT_SESSION_COMMANDS` or `DEFAULT_SESSION_AND_LIBRARY_COMMANDS` are set by default (depending on whether the `
mediaSession` is a `MediaLibrarySession`).

If the controller is not `trusted`, only `DEFAULT_UNTRUSTED_PLAYER_COMMANDS` and either `DEFAULT_UNTRUSTED_SESSION_COMMANDS` or `DEFAULT_UNTRUSTED_SESSION_AND_LIBRARY_COMMANDS` are set by default.

| Parameters |
|---|---|
| `mediaSession: MediaSession!` | The `MediaSession` for which to create a `ConnectionResult`. |
| `controllerInfo: MediaSession.ControllerInfo!` | The `ControllerInfo` for which to create a `ConnectionResult`. |

## Public functions

### build

```
fun build(): MediaSession.ConnectionResult!
```

Returns a new `ConnectionResult` instance for accepting a connection.

### setAvailablePlayerCommands

```
@CanIgnoreReturnValue
fun setAvailablePlayerCommands(availablePlayerCommands: Player.Commands!): MediaSession.ConnectionResult.AcceptedResultBuilder!
```

Sets the player commands that are available to the controller that gets this result returned when `connecting`.

This set of available player commands is intersected with the actual player commands supported by a player. The resulting intersection is the set of commands actually being available to a controller.

The default is `DEFAULT_PLAYER_COMMANDS`.

Interoperability: When accepting a connection from a ` platform or legacy controller`, this sets the internal player command permissions for that controller, but does not alter the visible playback actions of the shared platform session. Setting available player commands when accepting `the media notification controller` sets the available player commands of the shared platform session, which determines the visible playback actions (`getActions`) of the platform session.

### setAvailableSessionCommands

```
@CanIgnoreReturnValue
fun setAvailableSessionCommands(availableSessionCommands: SessionCommands!): MediaSession.ConnectionResult.AcceptedResultBuilder!
```

Sets the session commands that are available to the controller that gets this result returned when `connecting`.

The default is `DEFAULT_SESSION_AND_LIBRARY_COMMANDS` for a `MediaLibrarySession` and `DEFAULT_SESSION_COMMANDS` for a `MediaSession`.

Interoperability: When accepting a connection from a ` platform or legacy controller`, this sets the internal command permissions for that controller, but does not alter the visible custom actions of the shared platform session. Setting available session commands when accepting `the media notification controller` sets the session commands of the shared platform session, which determines which custom actions are enabled on the platform session.

### setCustomLayout

```
@CanIgnoreReturnValue
fun [setCustomLayout](https://developer.android.com/reference/kotlin/androidx/media3/session/MediaSession.ConnectionResult.AcceptedResultBuilder#setCustomLayout(java.util.List<androidx.media3.session.CommandButton>))(customLayout: (Mutable)List<CommandButton!>?): MediaSession.ConnectionResult.AcceptedResultBuilder!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `setMediaButtonPreferences` instead. Note that media button preferences use `slots` to define the allowed button placement.

### setMediaButtonPreferences

```
@CanIgnoreReturnValue
fun setMediaButtonPreferences(
    mediaButtonPreferences: (Mutable)List<CommandButton!>?
): MediaSession.ConnectionResult.AcceptedResultBuilder!
```

Sets the media button preferences, overriding the ` media button preferences of the session`.

The default is null to indicate that the media button preferences of the session should be used.

Make sure to have the session commands of all command buttons of the media button preferences included in the `available session commands`. On the controller side, the ` enabled` flag is set to `false` if the available commands of the controller do not allow to use a button.

Interoperability: This setting has no effect when accepting a connection from a `platform or legacy controller`. Setting media button preferences when accepting ` the media notification controller` sets the media button preferences and custom actions of the shared platform session.

### setSessionActivity

```
@CanIgnoreReturnValue
fun setSessionActivity(sessionActivity: PendingIntent?): MediaSession.ConnectionResult.AcceptedResultBuilder!
```

Sets the session activity, overriding the `session activity of the session`.

The default is null to indicate that the session activity of the session should be used.

Interoperability: This setting has no effect when accepting a connection from a `platform or legacy controller`. Setting a session activity when accepting ` the media notification controller` sets the session activity of the shared platform session.

### setSessionExtras

```
@CanIgnoreReturnValue
fun setSessionExtras(sessionExtras: Bundle!): MediaSession.ConnectionResult.AcceptedResultBuilder!
```

Sets the session extras, overriding the `extras of the session`.

The default is null to indicate that the extras of the session should be used.

Interoperability: This setting has no effect when accepting a connection from a `platform or legacy controller`. Setting session extras when accepting ` the media notification controller` sets the extras of the shared platform session.