Vinay
Vinay

Reputation: 4783

Android binder in native code

I have created the class which implements the Binder interface(Service). I am able to send the data to it from client.

If I want to send the asynchronous response back to client, do I need to implement Binder interface at client as well?

Upvotes: 2

Views: 2165

Answers (1)

SurlyDre
SurlyDre

Reputation: 473

Yes, you need to implement a Binder interface on the client as well. This is the way the Camera class and CameraService work together. The Camera class implements ICameraClient and it is passed to the server when connecting. In turn, the server returns an ICamera instance for the client to use.

sp<Camera> c = new Camera();
const sp<ICameraService>& cs = getCameraService();
if (cs != 0) {
    c->mCamera = cs->connect(c, cameraId);
}

Upvotes: 1

Related Questions