【问题标题】:Android binder in native code本机代码中的 Android 活页夹
【发布时间】:2010-12-20 14:20:46
【问题描述】:

我已经创建了实现 Binder 接口(服务)的类。我可以将数据从客户端发送给它。

如果我想将异步响应发送回客户端,是否还需要在客户端实现Binder接口?

【问题讨论】:

    标签: android c++ native-code android-binder


    【解决方案1】:

    是的,您还需要在客户端上实现一个 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);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-04
      • 1970-01-01
      • 1970-01-01
      • 2014-05-04
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      相关资源
      最近更新 更多