Android Guides | Samples

Android.OS.RemoteCallbackList Class

Takes care of the grunt work of maintaining a list of remote interfaces, typically for the use of performing callbacks from a Service to its clients.

See Also: RemoteCallbackList

Syntax

[Android.Runtime.Register("android/os/RemoteCallbackList", DoNotGenerateAcw=true)]
public class RemoteCallbackList : Object

Remarks

Takes care of the grunt work of maintaining a list of remote interfaces, typically for the use of performing callbacks from a Service to its clients. In particular, this:

  • Keeps track of a set of registered IInterface callbacks, taking care to identify them through their underlying unique BinderConsts (by calling IInterface.AsBinder.
  • Attaches a IBinderDeathRecipient to each registered interface, so that it can be cleaned out of the list if its process goes away.
  • Performs locking of the underlying list of interfaces to deal with multithreaded incoming calls, and a thread-safe way to iterate over a snapshot of the list without holding its lock.

To use this class, simply create a single instance along with your service, and call its RemoteCallbackList.register(E) and RemoteCallbackList.unregister(E) methods as client register and unregister with your service. To call back on to the registered clients, use RemoteCallbackList.BeginBroadcast, RemoteCallbackList.GetBroadcastItem(Int32), and RemoteCallbackList.FinishBroadcast.

If a registered callback's process goes away, this class will take care of automatically removing it from the list. If you want to do additional work in this situation, you can create a subclass that implements the RemoteCallbackList.onCallbackDied(E) method.

[Android Documentation]

Requirements

Namespace: Android.OS
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.OS.RemoteCallbackList are listed below.

See Also: Object

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
RegisteredCallbackCountInt32. Returns the number of registered callbacks.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

BeginBroadcast() : Int32
Prepare to start making calls to the currently registered callbacks.
FinishBroadcast()
Clean up the state of a broadcast previously initiated by calling RemoteCallbackList.BeginBroadcast.
GetBroadcastCookie(Int32) : Object
Retrieve the cookie associated with the item returned by RemoteCallbackList.GetBroadcastItem(Int32).
GetBroadcastItem(Int32) : Object
Retrieve an item in the active broadcast that was previously started with RemoteCallbackList.BeginBroadcast.
Kill()
Disable this callback list.
OnCallbackDied(Object)
OnCallbackDied(Object, Object)
Register(Object) : Boolean
Register(Object, Object) : Boolean
Unregister(Object) : Boolean