Android Guides | Samples

Android.OS.Binder Class

Base class for a remotable object, the core part of a lightweight remote procedure call mechanism defined by BinderConsts.

See Also: Binder

Syntax

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

Remarks

Base class for a remotable object, the core part of a lightweight remote procedure call mechanism defined by BinderConsts. This class is an implementation of IBinder that provides standard local implementation of such an object.

Most developers will not implement this class directly, instead using the aidl tool to describe the desired interface, having it generate the appropriate Binder subclass. You can, however, derive directly from Binder to implement your own custom RPC protocol or simply instantiate a raw Binder object directly to use as a token that can be shared across processes.

This class is just a basic IPC primitive; it has no impact on an application's lifecycle, and is valid only as long as the process that created it continues to run. To use this correctly, you must be doing so within the context of a top-level application component (a Service, Activity, or ContentProvider) that lets the system know your process should remain running.

You must keep in mind the situations in which your process could go away, and thus require that you later re-create a new Binder and re-attach it when the process starts again. For example, if you are using this within an Activity, your activity's process may be killed any time the activity is not started; if the activity is later re-created you will need to create a new Binder and hand it back to the correct place again; you need to be aware that your process may be started for another reason (for example to receive a broadcast) that will not involve re-creating the activity and thus run its code to create a new Binder.

See Also

[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.Binder are listed below.

See Also: Object

Public Constructors

Default constructor initializes the object.

Protected Constructors

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

Public Properties

[read-only]
static
CallingPidInt32. Return the ID of the process that sent you the current transaction that is being processed.
[read-only]
static
CallingUidInt32. Return the Linux uid assigned to the process that sent you the current transaction that is being processed.
[read-only]
static
CallingUserHandleUserHandle. Return the UserHandle assigned to the process that sent you the current transaction that is being processed.
[read-only]
InterfaceDescriptorString. Default implementation returns an empty interface name.
[read-only]
IsBinderAliveBoolean. Check to see if the process that the binder is in is still alive.

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

AttachInterface(IInterface, String)
Convenience method for associating a specific interface with the Binder.
static
ClearCallingIdentity() : Int64
Reset the identity of the incoming IPC on the current thread.
Dump(FileDescriptor, String[])
Implemented to call the more convenient version Binder.Dump(FileDescriptor,PrintWriter,PrintWriter).
DumpAsync(FileDescriptor, String[])
Like Binder.Dump(FileDescriptor,String[]), but ensures the target executes asynchronously.
static
FlushPendingCommands()
Flush any Binder commands pending in the current thread to the kernel driver.
static
JoinThreadPool()
Add the calling thread to the IPC thread pool.
LinkToDeath(IBinderDeathRecipient, Int32)
Local implementation is a no-op.
PingBinder() : Boolean
Default implementation always returns true -- if you got here, the object is alive.
QueryLocalInterface(String) : IInterface
Use information supplied to attachInterface() to return the associated IInterface if it matches the requested descriptor.
static
RestoreCallingIdentity(Int64)
Restore the identity of the incoming IPC on the current thread back to a previously identity that was returned by Binder.ClearCallingIdentity.
Transact(Int32, Parcel, Parcel, TransactionFlags) : Boolean
Default implementation rewinds the parcels and calls onTransact.
UnlinkToDeath(IBinderDeathRecipient, Int32) : Boolean
Local implementation is a no-op.

Protected Methods

Dump(FileDescriptor, PrintWriter, String[])
Print the object's state into the given stream.
OnTransact(Int32, Parcel, Parcel, Int32) : Boolean
Default implementation is a stub that returns false.