Android Binder(C++版本)

Posted we1less

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Binder(C++版本)相关的知识,希望对你有一定的参考价值。

BInder服务的C++实现

1.  定义接口类  其中定义抽象方法

IGodvService 
{
    //抽象方法
    sayhello
    sayhello_to
}

2. server端实现

BnGodvService : IGodvService
{
    //实现函数抽象方法
    sayhello
    sayhello_to
    //实现onTransact方法
    onTransact
       
}

3. client端实现

BpGodvService : IGodvService
{
    //实现函数抽象方法  构造数据把数据发送给service
    sayhello
    sayhello_to      
}

4.  实现service

main(){
    add service
    死循环{
       读数据  
       解析数据  
       调用服务函数 }
}

5.  实现client

main(){
    get service
    service->sayhello | service->sayhello_to
}

以上是关于Android Binder(C++版本)的主要内容,如果未能解决你的问题,请参考以下文章