Udostępnij za pośrednictwem


Binder Class

Definition

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

[Android.Runtime.Register("android/os/Binder", DoNotGenerateAcw=true)]
public class Binder : Java.Lang.Object, Android.OS.IBinder, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/os/Binder", DoNotGenerateAcw=true)>]
type Binder = class
    inherit Object
    interface IBinder
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Binder
Attributes
Implements

Remarks

Base class for a remotable object, the core part of a lightweight remote procedure call mechanism defined by IBinder. 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 android.app.Service, android.app.Activity, or android.content.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 android.app.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.

Java documentation for android.os.Binder.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Binder()

Default constructor just initializes the object.

Binder(IntPtr, JniHandleOwnership)

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

Binder(String)

Constructor for creating a raw Binder object (token) along with a descriptor.

Properties

CallingPid

Return the ID of the process that sent you the current transaction that is being processed.

CallingUid

Return the Linux UID assigned to the process that sent you the current transaction that is being processed.

CallingUidOrThrow

Return the Linux UID assigned to the process that sent the transaction currently being processed.

CallingUserHandle

Return the UserHandle assigned to the process that sent you the current transaction that is being processed.

CallingWorkSourceUid

Returns the work source set by the caller.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
InterfaceDescriptor

Default implementation returns an empty interface name.

IsBinderAlive

To be added

        Note that if you're calling on a local binder, this always returns true
        because your process is alive if you're calling it.
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AttachInterface(IInterface, String)

Convenience method for associating a specific interface with the Binder.

ClearCallingIdentity()

Reset the identity of the incoming IPC on the current thread.

ClearCallingWorkSource()

Clears the work source on this thread.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Dump(FileDescriptor, PrintWriter, String[])

Print the object's state into the given stream.

Dump(FileDescriptor, String[])

Implemented to call the more convenient version #dump(FileDescriptor, PrintWriter, String[]).

DumpAsync(FileDescriptor, String[])

Like #dump(FileDescriptor, String[]), but ensures the target executes asynchronously.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FlushPendingCommands()

Flush any Binder commands pending in the current thread to the kernel driver.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
JoinThreadPool()

Add the calling thread to the IPC thread pool.

LinkToDeath(IBinderDeathRecipient, Int32)

Local implementation is a no-op.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
OnTransact(Int32, Parcel, Parcel, Int32)

Default implementation is a stub that returns false.

PingBinder()

Default implementation always returns true -- if you got here, the object is alive.

QueryLocalInterface(String)

Use information supplied to #attachInterface attachInterface() to return the associated IInterface if it matches the requested descriptor.

RestoreCallingIdentity(Int64)

Restore the identity of the incoming IPC on the current thread back to a previously identity that was returned by #clearCallingIdentity.

RestoreCallingWorkSource(Int64)

Restores the work source on this thread using a token returned by #setCallingWorkSourceUid(int) or #clearCallingWorkSource().

SetCallingWorkSourceUid(Int32)

Sets the work source for this thread.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Transact(Int32, Parcel, Parcel, TransactionFlags)

Default implementation rewinds the parcels and calls onTransact.

UnlinkToDeath(IBinderDeathRecipient, Int32)

Local implementation is a no-op.

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to