# BroadcastReceiver.PendingResult

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

# PendingResult

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/content/BroadcastReceiver.PendingResult "View this page in Java")  

```
open class PendingResult
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                     ||
| ↳ | [android.content.BroadcastReceiver.PendingResult](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#) |

State for a result that is pending for a broadcast receiver. Returned by[goAsync()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#goAsync())while in[BroadcastReceiver.onReceive()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#onReceive(android.content.Context,%20android.content.Intent)). This allows you to return from onReceive() without having the broadcast terminate; you must call[finish()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#finish())once you are done with the broadcast. This allows you to process the broadcast off of the main thread of your app.

Note on threading: the state inside of this class is not itself thread-safe. However, you can use it from any thread if you make sure that you do not have races. Typically this means you will hand the entire object to another thread, which will be solely responsible for setting any results and finally calling[finish()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#finish()).

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                         Public methods                                                                                                                                                                                                                                                                                                                                                                                         ||
|------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [abortBroadcast](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#abortBroadcast())`()` Version of[BroadcastReceiver.abortBroadcast()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#abortBroadcast())for asynchronous broadcast handling.                                                                                                                                                                                                                                                                                                                                                                                |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [clearAbortBroadcast](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#clearAbortBroadcast())`()` Version of[BroadcastReceiver.clearAbortBroadcast()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#clearAbortBroadcast())for asynchronous broadcast handling.                                                                                                                                                                                                                                                                                                                                                            |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [finish](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#finish())`()` Finish the broadcast.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [getAbortBroadcast](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#getAbortBroadcast())`()` Version of[BroadcastReceiver.getAbortBroadcast()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#getAbortBroadcast())for asynchronous broadcast handling.                                                                                                                                                                                                                                                                                                                                                                    |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getResultCode](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#getResultCode())`()` Version of[BroadcastReceiver.getResultCode()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#getResultCode())for asynchronous broadcast handling.                                                                                                                                                                                                                                                                                                                                                                                    |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!  | [getResultData](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#getResultData())`()` Version of[BroadcastReceiver.getResultData()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#getResultData())for asynchronous broadcast handling.                                                                                                                                                                                                                                                                                                                                                                                    |
| [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!  | [getResultExtras](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#getResultExtras(kotlin.Boolean))`(`makeMap:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Version of[BroadcastReceiver.getResultExtras(boolean)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#getResultExtras(kotlin.Boolean))for asynchronous broadcast handling.                                                                                                                                                                                                                                          |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setResult](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#setResult(kotlin.Int,%20kotlin.String,%20android.os.Bundle))`(`code:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `data:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` Version of[BroadcastReceiver.setResult(int, String, Bundle)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#setResult(kotlin.Int,%20kotlin.String,%20android.os.Bundle))for asynchronous broadcast handling. |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setResultCode](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#setResultCode(kotlin.Int))`(`code:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Version of[BroadcastReceiver.setResultCode(int)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#setResultCode(kotlin.Int))for asynchronous broadcast handling.                                                                                                                                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setResultData](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#setResultData(kotlin.String))`(`data:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Version of[BroadcastReceiver.setResultData(String)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#setResultData(kotlin.String))for asynchronous broadcast handling.                                                                                                                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setResultExtras](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult#setResultExtras(android.os.Bundle))`(`extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` Version of[BroadcastReceiver.setResultExtras(Bundle)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#setResultExtras(android.os.Bundle))for asynchronous broadcast handling.                                                                                                                                                                                                                                       |

## Public methods

### abortBroadcast

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

```
fun abortBroadcast(): Unit
```

Version of[BroadcastReceiver.abortBroadcast()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#abortBroadcast())for asynchronous broadcast handling.  

### clearAbortBroadcast

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

```
fun clearAbortBroadcast(): Unit
```

Version of[BroadcastReceiver.clearAbortBroadcast()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#clearAbortBroadcast())for asynchronous broadcast handling.  

### finish

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

```
fun finish(): Unit
```

Finish the broadcast. The current result will be sent and the next broadcast will proceed.  

### getAbortBroadcast

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

```
fun getAbortBroadcast(): Boolean
```

Version of[BroadcastReceiver.getAbortBroadcast()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#getAbortBroadcast())for asynchronous broadcast handling.  

### getResultCode

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

```
fun getResultCode(): Int
```

Version of[BroadcastReceiver.getResultCode()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#getResultCode())for asynchronous broadcast handling.  

### getResultData

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

```
fun getResultData(): String!
```

Version of[BroadcastReceiver.getResultData()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#getResultData())for asynchronous broadcast handling.  

### getResultExtras

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

```
fun getResultExtras(makeMap: Boolean): Bundle!
```

Version of[BroadcastReceiver.getResultExtras(boolean)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#getResultExtras(kotlin.Boolean))for asynchronous broadcast handling.  

### setResult

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

```
fun setResult(
    code: Int, 
    data: String!, 
    extras: Bundle!
): Unit
```

Version of[BroadcastReceiver.setResult(int, String, Bundle)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#setResult(kotlin.Int,%20kotlin.String,%20android.os.Bundle))for asynchronous broadcast handling.  

### setResultCode

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

```
fun setResultCode(code: Int): Unit
```

Version of[BroadcastReceiver.setResultCode(int)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#setResultCode(kotlin.Int))for asynchronous broadcast handling.  

### setResultData

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

```
fun setResultData(data: String!): Unit
```

Version of[BroadcastReceiver.setResultData(String)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#setResultData(kotlin.String))for asynchronous broadcast handling.  

### setResultExtras

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

```
fun setResultExtras(extras: Bundle!): Unit
```

Version of[BroadcastReceiver.setResultExtras(Bundle)](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver#setResultExtras(android.os.Bundle))for asynchronous broadcast handling.