当前位置: 首页 > wzjs >正文

网站建设参考文献2017网站设计模块

网站建设参考文献2017,网站设计模块,网站建设收费,做平台网站要什么条件书接上回,继续第三种方式,是手动生成 service binder 的方法,项目结构 1,编译aidl aidl 文件保持不变,如何生成Bn和Bp 文件呢。 aidl -I ./libserviceaidl/aidl -h ./ -o ./ --langcpp libserviceaidl/aidl/com/test/IService.a…

书接上回,继续第三种方式,是手动生成 service binder 的方法,项目结构

1,编译aidl

aidl 文件保持不变,如何生成Bn和Bp 文件呢。

aidl -I ./libserviceaidl/aidl -h ./ -o ./ --lang=cpp libserviceaidl/aidl/com/test/IService.aidl

aidl -I ./libserviceaidl/aidl -h ./ -o ./ --lang=cpp libserviceaidl/aidl/com/test/IServiceCallback.aidl

  -I aidi 文件目录  -h头文件生成路径  -o cpp文件存放路径

2,Native service 差别不大

#define LOG_TAG "testservverfirst"
#include <log/log.h>#include <unistd.h>
#include <stdlib.h>
#include <utils/RefBase.h>
#include <utils/Log.h>
#include <binder/TextOutput.h>
#include <binder/IInterface.h>
#include <binder/IBinder.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <binder/IPCThreadState.h>
#include <termios.h> 
#include <utils/String16.h>
#include "com/test/BnService.h"
#include "com/test/BnServiceCallback.h"using namespace std;
using namespace android;class TestService : public com::test::BnService 
{public:TestService(){}binder::Status nativecall(int i) {ALOGI("server nativecall function is running %d",i);if(mycallback != nullptr){mycallback->onEventString(4,String16("callbacksuccuess"));}return binder::Status();}binder::Status  callMcu(int32_t file,const vector<uint8_t>& type, int32_t* _aidl_return){*_aidl_return = 1;ALOGI("server callMcu function is running _aidl_return",*_aidl_return);return binder::Status();}binder::Status  call(int32_t type){ALOGI("server call function is running call %d",type);return binder::Status();}// 实现回调注册binder::Status registerCallback(const sp<com::test::IServiceCallback>& callback){mycallback  = callback;return binder::Status();}private:sp<::com::test::IServiceCallback> mycallback;};int main(int argc, char const *argv[])
{ALOGD("Server is runing");defaultServiceManager()->addService(String16("TestService"), new TestService());ProcessState::self()->startThreadPool();IPCThreadState::self()->joinThreadPool();return 0;
}

C++ 调用前面有介绍,最后补充下java 的调用方式。

3,Java 调用

try {Class<?> clazz = Class.forName("android.os.ServiceManager");Method method = clazz.getMethod("getService",String.class);IBinder binder = (IBinder) method.invoke(null,"TestService");if (binder != null){IService iservice = IService.Stub.asInterface(binder);// 千万不要忘记注册iservice.registerCallback(mycallback);iservice.call(1);}
} catch (ClassNotFoundException | NoSuchMethodException e) {e.printStackTrace();
} catch (IllegalAccessException e) {e.printStackTrace();
} catch (InvocationTargetException e) {e.printStackTrace();
} catch (RemoteException e) {e.printStackTrace();
}

或者系统里面

 IService.Stub.asInterface(ServiceManager.getService("TestService"));

参考

[Android AIDL系列 1] 手动编译aidl文件,生成Java、C++[android]、C++[ndk]、Rust接口_aidl c++-CSDN博客


文章转载自:

http://hAB6MsjZ.Lssfd.cn
http://pASgCtXC.Lssfd.cn
http://Nucd7O76.Lssfd.cn
http://9gUvTNhx.Lssfd.cn
http://Vj9ksdUb.Lssfd.cn
http://KpH2GwDA.Lssfd.cn
http://nY25GADf.Lssfd.cn
http://btRlVHvj.Lssfd.cn
http://r9vEPlbJ.Lssfd.cn
http://UUiNOEqg.Lssfd.cn
http://XNQMXPPz.Lssfd.cn
http://KSuTwSRn.Lssfd.cn
http://uzz00mrE.Lssfd.cn
http://x98VOhEF.Lssfd.cn
http://kU8lsqji.Lssfd.cn
http://JVIMVLZN.Lssfd.cn
http://G8gu8dXH.Lssfd.cn
http://Fj9dKalZ.Lssfd.cn
http://ad7XmxWq.Lssfd.cn
http://AIIIjvkq.Lssfd.cn
http://jsIzDVJR.Lssfd.cn
http://1G8nMrco.Lssfd.cn
http://pqVsrFqo.Lssfd.cn
http://ItVfar22.Lssfd.cn
http://P8e7UQXv.Lssfd.cn
http://PUWOxhH7.Lssfd.cn
http://h1BR6EW2.Lssfd.cn
http://GggARFQs.Lssfd.cn
http://AUz3KGeK.Lssfd.cn
http://VXGlYTDc.Lssfd.cn
http://www.dtcms.com/wzjs/768512.html

相关文章:

  • 添加网站描述哪个网站帮别人做ppt
  • html5的网站有哪些seo推广计划
  • 视频教做家常菜的网站wordpress社交模板
  • 建设部人才网站黄骅港船舶动态信息平台
  • 马鞍山市网站建设服务有限公司深圳网站排名
  • 凡科建的网站可以做seo吗ppt设计网站
  • 新密网站建设wordpress移动端音频播放
  • 网站整站出售学校网站建设的意义与途径
  • 大德通众包做网站怎么样网站推广岗位的要求
  • 苏州网站建设搭建比较好的wordpress
  • 怎么做网站赚钱南昌科技网站建设
  • 简约网站模板html南宁经典网站建设
  • 东莞做网站公司排名收到网站建设费分录
  • 平度市网站建设建筑设计建模软件
  • 衡水网站建设电话个人网站可以做导航
  • 西宁市建设网站多少钱做翻译的网站
  • 自定义功能的网站开发公司延迟缴纳维修基金申请书
  • app软件开发培训班seo内容优化是什么
  • 有了域名怎么建网站联系方式wordpress怎么添加登录
  • 平面设计高端网站网页界面设计欣赏
  • 内蒙古建设工程造价信息网官方网站中国建设网app下载
  • 仕德伟做的网站滁州市南谯区住房和建设局网站
  • 做啥网站赚钱?做网站外包公司
  • 网站建设岗位廉政风险防控响应式网站制作工具
  • 快速搭建网站python我的长沙app是哪里开发的
  • 学校网站建设全包百度网站验证方法
  • 菏泽网站建设培训学校建设网站有什么作用
  • 东莞网站seo做模板网站
  • 如何用front怕个做网站上海闵行建设局官方网站
  • 公司向要做一个网站要怎么做建设厅执业资格注册中心网站