# SessionResult

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

*** ** * ** ***


```
public final class SessionResult
```

<br />

*** ** * ** ***

A result to be used with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` for asynchronous calls between `https://developer.android.com/reference/androidx/media3/session/MediaSession` and `https://developer.android.com/reference/androidx/media3/session/MediaController`.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = [https://developer.android.com/reference/androidx/media3/session/SessionError.INFO_CANCELLED, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_UNKNOWN, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_INVALID_STATE, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_BAD_VALUE, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_PERMISSION_DENIED, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_IO, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_SESSION_DISCONNECTED, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_NOT_SUPPORTED, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_SESSION_AUTHENTICATION_EXPIRED, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_SESSION_CONCURRENT_STREAM_LIMIT, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_SESSION_NOT_AVAILABLE_IN_REGION, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_SESSION_SKIP_LIMIT_REACHED, https://developer.android.com/reference/androidx/media3/session/SessionError.ERROR_SESSION_SETUP_REQUIRED]) public annotation https://developer.android.com/reference/androidx/media3/session/SessionResult.Code` Result codes. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_BAD_VALUE() = -3` Result code representing that an argument is illegal. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_INVALID_STATE() = -2` Result code representing that the command cannot be completed because the current state is not valid for the command. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_IO() = -5` Result code representing that a file or network related error happened. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_NOT_SUPPORTED() = -6` Result code representing that the command is not supported. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_PERMISSION_DENIED() = -4` Result code representing that the command is not allowed. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED() = -102` Result code representing that the authentication has expired. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_SESSION_CONCURRENT_STREAM_LIMIT() = -104` Result code representing that too many concurrent streams are detected. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_SESSION_DISCONNECTED() = -100` Result code representing that the session and controller were disconnected. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_SESSION_NOT_AVAILABLE_IN_REGION() = -106` Result code representing that the content is blocked due to being regionally unavailable. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED() = -105` Result code representing that the content is blocked due to parental controls. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED() = -103` Result code representing that a premium account is required. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_SESSION_SETUP_REQUIRED() = -108` Result code representing that the session needs user's manual intervention. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_SESSION_SKIP_LIMIT_REACHED() = -107` Result code representing that the application cannot skip any more because the skip limit is reached. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_ERROR_UNKNOWN() = -1` Result code representing that the command is ended with an unknown error. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_INFO_SKIPPED() = 1` Result code representing that the command is skipped. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_SUCCESS() = 0` Result code representing that the command is successfully completed. |

| ### Public fields |
|---|---|
| `final long` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#completionTimeMs()` The completion time of the command. |
| `final https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/media3/session/SessionResult#extras()` The extra `https://developer.android.com/reference/android/os/Bundle.html` for the result. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/session/SessionResult.Code https://developer.android.com/reference/androidx/media3/session/SessionResult#resultCode()` The `https://developer.android.com/reference/androidx/media3/session/SessionResult.Code` of this result. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/session/SessionError` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/SessionResult#sessionError()` The optional session error. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/session/SessionResult#SessionResult(int)(@https://developer.android.com/reference/androidx/media3/session/SessionResult.Code int resultCode)` Creates an instance with a result code. |
| `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/SessionResult#SessionResult(androidx.media3.session.SessionError)(https://developer.android.com/reference/androidx/media3/session/SessionError sessionError)` Creates an instance from a `https://developer.android.com/reference/androidx/media3/session/SessionError`. |
| `https://developer.android.com/reference/androidx/media3/session/SessionResult#SessionResult(int,android.os.Bundle)(@https://developer.android.com/reference/androidx/media3/session/SessionResult.Code int resultCode, https://developer.android.com/reference/android/os/Bundle.html extras)` Creates an instance with a result code and an extra `https://developer.android.com/reference/android/os/Bundle.html`. |
| `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/SessionResult#SessionResult(androidx.media3.session.SessionError,android.os.Bundle)(https://developer.android.com/reference/androidx/media3/session/SessionError sessionError, https://developer.android.com/reference/android/os/Bundle.html extras)` Creates an instance from a `https://developer.android.com/reference/androidx/media3/session/SessionError` and an extras `https://developer.android.com/reference/android/os/Bundle.html`. |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/media3/session/SessionResult` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/SessionResult#fromBundle(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html bundle)` Restores a `SessionResult` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `https://developer.android.com/reference/android/os/Bundle.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/SessionResult#toBundle()()` |

## Constants

### RESULT_ERROR_BAD_VALUE

```
public static final int RESULT_ERROR_BAD_VALUE = -3
```

Result code representing that an argument is illegal.

### RESULT_ERROR_INVALID_STATE

```
public static final int RESULT_ERROR_INVALID_STATE = -2
```

Result code representing that the command cannot be completed because the current state is not valid for the command.

### RESULT_ERROR_IO

```
public static final int RESULT_ERROR_IO = -5
```

Result code representing that a file or network related error happened.

### RESULT_ERROR_NOT_SUPPORTED

```
public static final int RESULT_ERROR_NOT_SUPPORTED = -6
```

Result code representing that the command is not supported.

### RESULT_ERROR_PERMISSION_DENIED

```
public static final int RESULT_ERROR_PERMISSION_DENIED = -4
```

Result code representing that the command is not allowed.

### RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED

```
public static final int RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED = -102
```

Result code representing that the authentication has expired.

### RESULT_ERROR_SESSION_CONCURRENT_STREAM_LIMIT

```
public static final int RESULT_ERROR_SESSION_CONCURRENT_STREAM_LIMIT = -104
```

Result code representing that too many concurrent streams are detected.

### RESULT_ERROR_SESSION_DISCONNECTED

```
public static final int RESULT_ERROR_SESSION_DISCONNECTED = -100
```

Result code representing that the session and controller were disconnected.

### RESULT_ERROR_SESSION_NOT_AVAILABLE_IN_REGION

```
public static final int RESULT_ERROR_SESSION_NOT_AVAILABLE_IN_REGION = -106
```

Result code representing that the content is blocked due to being regionally unavailable.

### RESULT_ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED

```
public static final int RESULT_ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED = -105
```

Result code representing that the content is blocked due to parental controls.

### RESULT_ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED

```
public static final int RESULT_ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED = -103
```

Result code representing that a premium account is required.

### RESULT_ERROR_SESSION_SETUP_REQUIRED

```
public static final int RESULT_ERROR_SESSION_SETUP_REQUIRED = -108
```

Result code representing that the session needs user's manual intervention.

### RESULT_ERROR_SESSION_SKIP_LIMIT_REACHED

```
public static final int RESULT_ERROR_SESSION_SKIP_LIMIT_REACHED = -107
```

Result code representing that the application cannot skip any more because the skip limit is reached.

### RESULT_ERROR_UNKNOWN

```
public static final int RESULT_ERROR_UNKNOWN = -1
```

Result code representing that the command is ended with an unknown error.

### RESULT_INFO_SKIPPED

```
public static final int RESULT_INFO_SKIPPED = 1
```

Result code representing that the command is skipped.

### RESULT_SUCCESS

```
public static final int RESULT_SUCCESS = 0
```

Result code representing that the command is successfully completed.

Interoperability: This code is also used to tell that the command was successfully sent, but the result is unknown when connected with `
android.support.v4.media.session.MediaSessionCompat` or `
android.support.v4.media.session.MediaControllerCompat`.

## Public fields

### completionTimeMs

```
public final long completionTimeMs
```

The completion time of the command. It's the same as `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` when the command is completed.

### extras

```
public final Bundle extras
```

The extra `https://developer.android.com/reference/android/os/Bundle.html` for the result.

### resultCode

```
@SessionResult.Code
public final int resultCode
```

The `https://developer.android.com/reference/androidx/media3/session/SessionResult.Code` of this result.

Value is one of the following:

- `SessionError.INFO_CANCELLED`
- `SessionError.ERROR_UNKNOWN`
- `SessionError.ERROR_INVALID_STATE`
- `SessionError.ERROR_BAD_VALUE`
- `SessionError.ERROR_PERMISSION_DENIED`
- `SessionError.ERROR_IO`
- `SessionError.ERROR_SESSION_DISCONNECTED`
- `SessionError.ERROR_NOT_SUPPORTED`
- `SessionError.ERROR_SESSION_AUTHENTICATION_EXPIRED`
- `SessionError.ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED`
- `SessionError.ERROR_SESSION_CONCURRENT_STREAM_LIMIT`
- `SessionError.ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED`
- `SessionError.ERROR_SESSION_NOT_AVAILABLE_IN_REGION`
- `SessionError.ERROR_SESSION_SKIP_LIMIT_REACHED`
- `SessionError.ERROR_SESSION_SETUP_REQUIRED`

<br />

### sessionError

```
@UnstableApi
public final @Nullable SessionError sessionError
```

The optional session error.

## Public constructors

### SessionResult

```
public SessionResult(@SessionResult.Code int resultCode)
```

Creates an instance with a result code.

Note: Use `https://developer.android.com/reference/androidx/media3/session/SessionResult#SessionResult(androidx.media3.session.SessionError)` for errors to provide a localized error message for your users.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/session/SessionResult.Code int resultCode` | The result code. Value is one of the following: - `SessionError.INFO_CANCELLED` - `SessionError.ERROR_UNKNOWN` - `SessionError.ERROR_INVALID_STATE` - `SessionError.ERROR_BAD_VALUE` - `SessionError.ERROR_PERMISSION_DENIED` - `SessionError.ERROR_IO` - `SessionError.ERROR_SESSION_DISCONNECTED` - `SessionError.ERROR_NOT_SUPPORTED` - `SessionError.ERROR_SESSION_AUTHENTICATION_EXPIRED` - `SessionError.ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED` - `SessionError.ERROR_SESSION_CONCURRENT_STREAM_LIMIT` - `SessionError.ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED` - `SessionError.ERROR_SESSION_NOT_AVAILABLE_IN_REGION` - `SessionError.ERROR_SESSION_SKIP_LIMIT_REACHED` - `SessionError.ERROR_SESSION_SETUP_REQUIRED` <br /> |

### SessionResult

```
@UnstableApi
public SessionResult(SessionError sessionError)
```

Creates an instance from a `https://developer.android.com/reference/androidx/media3/session/SessionError`. The `https://developer.android.com/reference/androidx/media3/session/SessionResult#resultCode()` is taken from `https://developer.android.com/reference/androidx/media3/session/SessionError#code()` and the session result extras `https://developer.android.com/reference/android/os/Bundle.html` is empty.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/SessionError sessionError` | The `https://developer.android.com/reference/androidx/media3/session/SessionError`. |

### SessionResult

```
public SessionResult(@SessionResult.Code int resultCode, Bundle extras)
```

Creates an instance with a result code and an extra `https://developer.android.com/reference/android/os/Bundle.html`.

Note: Use `https://developer.android.com/reference/androidx/media3/session/SessionResult#SessionResult(androidx.media3.session.SessionError,android.os.Bundle)` for errors to provide a localized error message for your users.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/session/SessionResult.Code int resultCode` | The result code. Value is one of the following: - `SessionError.INFO_CANCELLED` - `SessionError.ERROR_UNKNOWN` - `SessionError.ERROR_INVALID_STATE` - `SessionError.ERROR_BAD_VALUE` - `SessionError.ERROR_PERMISSION_DENIED` - `SessionError.ERROR_IO` - `SessionError.ERROR_SESSION_DISCONNECTED` - `SessionError.ERROR_NOT_SUPPORTED` - `SessionError.ERROR_SESSION_AUTHENTICATION_EXPIRED` - `SessionError.ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED` - `SessionError.ERROR_SESSION_CONCURRENT_STREAM_LIMIT` - `SessionError.ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED` - `SessionError.ERROR_SESSION_NOT_AVAILABLE_IN_REGION` - `SessionError.ERROR_SESSION_SKIP_LIMIT_REACHED` - `SessionError.ERROR_SESSION_SETUP_REQUIRED` <br /> |
| `https://developer.android.com/reference/android/os/Bundle.html extras` | The extra `https://developer.android.com/reference/android/os/Bundle.html`. |

### SessionResult

```
@UnstableApi
public SessionResult(SessionError sessionError, Bundle extras)
```

Creates an instance from a `https://developer.android.com/reference/androidx/media3/session/SessionError` and an extras `https://developer.android.com/reference/android/os/Bundle.html`. The `https://developer.android.com/reference/androidx/media3/session/SessionResult#resultCode()` is taken from the `https://developer.android.com/reference/androidx/media3/session/SessionError`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/SessionError sessionError` | The `https://developer.android.com/reference/androidx/media3/session/SessionError`. |
| `https://developer.android.com/reference/android/os/Bundle.html extras` | The extra `https://developer.android.com/reference/android/os/Bundle.html`. |

## Public methods

### fromBundle

```
@UnstableApi
public static SessionResult fromBundle(Bundle bundle)
```

Restores a `SessionResult` from a `https://developer.android.com/reference/android/os/Bundle.html`.

### toBundle

```
@UnstableApi
public Bundle toBundle()
```