Sunday, January 22, 2012

Binder as IBinder for android

Binder is the base class for the remoteable object. The core part of a lightweight remote call procedure mechanism. This class is an implementation of IBinder that provides the standard support creating a local implementation of such an object


Most developer will not implement directly from this class instead use aidl tool. (I do not know anything about that tool!! :-P). We can however derive directly from Binder to implement our own custom RPC protocol



private final IBinder mbinder = new LocalBinder();
public class LocalBinder extends Binder {
LocalService getService() {
return LocalService.this;
}
}

(or) create a raw Binder object directly to use as a token that can be shared acrosses processes.

1 comment: