Added in API level 11

PendingResult


open class PendingResult
kotlin.Any
   ↳ android.content.BroadcastReceiver.PendingResult

State for a result that is pending for a broadcast receiver. Returned by goAsync() while in BroadcastReceiver.onReceive(). This allows you to return from onReceive() without having the broadcast terminate; you must call 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().

Summary

Public methods
Unit

Version of BroadcastReceiver.abortBroadcast() for asynchronous broadcast handling.

Unit

Version of BroadcastReceiver.clearAbortBroadcast() for asynchronous broadcast handling.

Unit

Finish the broadcast.

Boolean

Version of BroadcastReceiver.getAbortBroadcast() for asynchronous broadcast handling.

Int

Version of BroadcastReceiver.getResultCode() for asynchronous broadcast handling.

String!

Version of BroadcastReceiver.getResultData() for asynchronous broadcast handling.

Bundle!

Version of BroadcastReceiver.getResultExtras(boolean) for asynchronous broadcast handling.

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

Version of BroadcastReceiver.setResult(int, String, Bundle) for asynchronous broadcast handling.

Unit

Version of BroadcastReceiver.setResultCode(int) for asynchronous broadcast handling.

Unit

Version of BroadcastReceiver.setResultData(String) for asynchronous broadcast handling.

Unit

Version of BroadcastReceiver.setResultExtras(Bundle) for asynchronous broadcast handling.

Public methods

abortBroadcast

Added in API level 11
fun abortBroadcast(): Unit

Version of BroadcastReceiver.abortBroadcast() for asynchronous broadcast handling.

clearAbortBroadcast

Added in API level 11
fun clearAbortBroadcast(): Unit

Version of BroadcastReceiver.clearAbortBroadcast() for asynchronous broadcast handling.

finish

Added in API level 11
fun finish(): Unit

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

getAbortBroadcast

Added in API level 11
fun getAbortBroadcast(): Boolean

Version of BroadcastReceiver.getAbortBroadcast() for asynchronous broadcast handling.

getResultCode

Added in API level 11
fun getResultCode(): Int

Version of BroadcastReceiver.getResultCode() for asynchronous broadcast handling.

getResultData

Added in API level 11
fun getResultData(): String!

Version of BroadcastReceiver.getResultData() for asynchronous broadcast handling.

getResultExtras

Added in API level 11
fun getResultExtras(makeMap: Boolean): Bundle!

Version of BroadcastReceiver.getResultExtras(boolean) for asynchronous broadcast handling.

setResult

Added in API level 11
fun setResult(
    code: Int,
    data: String!,
    extras: Bundle!
): Unit

Version of BroadcastReceiver.setResult(int, String, Bundle) for asynchronous broadcast handling.

setResultCode

Added in API level 11
fun setResultCode(code: Int): Unit

Version of BroadcastReceiver.setResultCode(int) for asynchronous broadcast handling.

setResultData

Added in API level 11
fun setResultData(data: String!): Unit

Version of BroadcastReceiver.setResultData(String) for asynchronous broadcast handling.

setResultExtras

Added in API level 11
fun setResultExtras(extras: Bundle!): Unit

Version of BroadcastReceiver.setResultExtras(Bundle) for asynchronous broadcast handling.