to top
Android APIs
public static class

BroadcastReceiver.PendingResult

extends Object
java.lang.Object
   ↳ android.content.BroadcastReceiver.PendingResult

Class Overview

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 properly 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

? Examples
final void abortBroadcast()
Version of BroadcastReceiver.abortBroadcast() for asynchronous broadcast handling.

? Examples
final void clearAbortBroadcast()
Version of BroadcastReceiver.clearAbortBroadcast() for asynchronous broadcast handling.

? Examples
final void finish()
Finish the broadcast.

? Examples
final boolean getAbortBroadcast()
Version of BroadcastReceiver.getAbortBroadcast() for asynchronous broadcast handling.

? Examples
final int getResultCode()
Version of BroadcastReceiver.getResultCode() for asynchronous broadcast handling.

? Examples
final String getResultData()
Version of BroadcastReceiver.getResultData() for asynchronous broadcast handling.

? Examples
final Bundle getResultExtras(boolean makeMap)
Version of BroadcastReceiver.getResultExtras(boolean) for asynchronous broadcast handling.

? Examples
final void setResult(int code, String data, Bundle extras)
Version of BroadcastReceiver.setResult(int, String, Bundle) for asynchronous broadcast handling.

? Examples
final void setResultCode(int code)
Version of BroadcastReceiver.setResultCode(int) for asynchronous broadcast handling.

? Examples
final void setResultData( String data)
Version of BroadcastReceiver.setResultData(String) for asynchronous broadcast handling.

? Examples
final void setResultExtras( Bundle extras)
Version of BroadcastReceiver.setResultExtras(Bundle) for asynchronous broadcast handling.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public final void abortBroadcast ()

Added in API level 11

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

public final void clearAbortBroadcast ()

Added in API level 11

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

public final void finish ()

Added in API level 11

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

public final boolean getAbortBroadcast ()

Added in API level 11

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

public final int getResultCode ()

Added in API level 11

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

public final String getResultData ()

Added in API level 11

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

public final Bundle getResultExtras (boolean makeMap)

Added in API level 11

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

public final void setResult (int code, String data, Bundle extras)

Added in API level 11

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

public final void setResultCode (int code)

Added in API level 11

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

public final void setResultData (String data)

Added in API level 11

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

public final void setResultExtras (Bundle extras)

Added in API level 11

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

No examples for this method.
Frequently called with: [Clear]
Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. The original page is available here.