# MediaBrowserServiceCompat.Result

Artifact: [androidx.media:media](https://developer.android.com/jetpack/androidx/releases/media) [View Source](https://cs.android.com/search?q=file:androidx/media/MediaBrowserServiceCompat.java+class:androidx.media.MediaBrowserServiceCompat.Result) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

*** ** * ** ***


```
class MediaBrowserServiceCompat.Result<T>
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> androidx.media is deprecated. Please migrate to [androidx.media3](https://developer.android.com/media/media3).

Completion handler for asynchronous callback methods in `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat`.

Each of the methods that takes one of these to send the result must call either `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendResult(T)` or `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendError(android.os.Bundle)` to respond to the caller with the given results or errors. If those functions return without calling `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendResult(T)` or `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendError(android.os.Bundle)`, they must instead call `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#detach()` before returning, and then may call `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendResult(T)` or `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendError(android.os.Bundle)` when they are done. If `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendResult(T)`, `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendError(android.os.Bundle)`, or `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#detach()` is called twice, an exception will be thrown.

Those functions might also want to call `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendProgressUpdate(android.os.Bundle)` to send interim updates to the caller. If it is called after calling `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendResult(T)` or `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendError(android.os.Bundle)`, an exception will be thrown.

| Parameters |
|---|---|
| `<T>` | The type of the result |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat#onLoadChildren(java.lang.String,androidx.media.MediaBrowserServiceCompat.Result<java.util.List<android.support.v4.media.MediaBrowserCompat.MediaItem>>)` |   |
| `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat#onLoadItem(java.lang.String,androidx.media.MediaBrowserServiceCompat.Result<android.support.v4.media.MediaBrowserCompat.MediaItem>)` |   |
| `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat#onSearch(java.lang.String,android.os.Bundle,androidx.media.MediaBrowserServiceCompat.Result<java.util.List<android.support.v4.media.MediaBrowserCompat.MediaItem>>)` |   |
| `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat#onCustomAction(java.lang.String,android.os.Bundle,androidx.media.MediaBrowserServiceCompat.Result<android.os.Bundle>)` |   |

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[detach](https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#detach())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[sendError](https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendError(android.os.Bundle))(extras: https://developer.android.com/reference/android/os/Bundle.html?)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[sendProgressUpdate](https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendProgressUpdate(android.os.Bundle))(extras: https://developer.android.com/reference/android/os/Bundle.html?)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[sendResult](https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendResult(T))(result: T?)` **This function is deprecated.** Deprecated in Java |

## Public functions

### detach

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [detach](https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#detach())(): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Detach this message from the current thread and allow the `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendResult(T)` call to happen later.

### sendError

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [sendError](https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendError(android.os.Bundle))(extras: Bundle?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Notify the caller of a failure. This is supported only when it is used in `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat#onCustomAction(java.lang.String,android.os.Bundle,androidx.media.MediaBrowserServiceCompat.Result<android.os.Bundle>)`.

| Parameters |
|---|---|
| `extras: https://developer.android.com/reference/android/os/Bundle.html?` | A bundle that contains extra data. |

### sendProgressUpdate

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [sendProgressUpdate](https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendProgressUpdate(android.os.Bundle))(extras: Bundle?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Send an interim update to the caller. This method is supported only when it is used in `https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat#onCustomAction(java.lang.String,android.os.Bundle,androidx.media.MediaBrowserServiceCompat.Result<android.os.Bundle>)`.

| Parameters |
|---|---|
| `extras: https://developer.android.com/reference/android/os/Bundle.html?` | A bundle that contains extra data. |

### sendResult

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [sendResult](https://developer.android.com/reference/kotlin/androidx/media/MediaBrowserServiceCompat.Result#sendResult(T))(result: T?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Send the result back to the caller.