【发布时间】:2010-12-20 14:20:46
【问题描述】:
我已经创建了实现 Binder 接口(服务)的类。我可以将数据从客户端发送给它。
如果我想将异步响应发送回客户端,是否还需要在客户端实现Binder接口?
【问题讨论】:
标签: android c++ native-code android-binder
我已经创建了实现 Binder 接口(服务)的类。我可以将数据从客户端发送给它。
如果我想将异步响应发送回客户端,是否还需要在客户端实现Binder接口?
【问题讨论】:
标签: android c++ native-code android-binder
是的,您还需要在客户端上实现一个 Binder 接口。这就是 Camera 类和 CameraService 一起工作的方式。 Camera 类实现 ICameraClient 并在连接时传递给服务器。反过来,服务器返回一个 ICamera 实例供客户端使用。
sp<Camera> c = new Camera();
const sp<ICameraService>& cs = getCameraService();
if (cs != 0) {
c->mCamera = cs->connect(c, cameraId);
}
【讨论】: