简体   繁体   English

本机代码中的Android活页夹

[英]Android binder in native code

I have created the class which implements the Binder interface(Service). 我创建了实现Binder接口(服务)的类。 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? 如果我想将异步响应发送回客户端,是否还需要在客户端实现Binder接口?

Yes, you need to implement a Binder interface on the client as well. 是的,您还需要在客户端上实现Binder接口。 This is the way the Camera class and CameraService work together. 这是Camera类和CameraService协同工作的方式。 The Camera class implements ICameraClient and it is passed to the server when connecting. Camera类实现ICameraClient,并且在连接时将其传递到服务器。 In turn, the server returns an ICamera instance for the client to use. 反过来,服务器返回一个ICamera实例供客户端使用。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM