当前位置:网站首页>AIDL communication
AIDL communication
2022-08-01 21:35:00 【shuo277】
1.1AIDL Introduction
AIDL (Android Interface Definition Language), which can be used to define a programming interface for client-server inter-process communication (IPC).In the Android system, each process runs in an independent memory, completes its own activities in it, and is separated from other processes.But sometimes we have the need for interaction between applications, such as data transfer or task delegation, etc. AIDL was born to meet this need.Through AIDL, data of another process can be obtained in one process and its exposed methods can be called, so as to meet the needs of inter-process communication.
AIDL is a description language used to define the communication interface between the server and the client. It can be used to produce IPC code. In a sense, AIDL is actually a template, because in the process of use, the actual workingIt is not an AIDL file, but an instance code of an Interface produced based on it. AIDL is actually a template that appears to prevent us from repeatedly writing code.
Note: AIDL is only necessary if you need clients from different applications to access the service via IPC, and if you want multithreading in the service.If you don't need to perform concurrent IPC across different applications, you should create the interface by implementing Binder; alternatively, if you want to perform IPC but don't need to deal with multithreading, use Messenger to implement the interface.In any case, it is important that you understand binding services before implementing AIDL.
1.2 Usage process
1. Define the AIDL interface in the .aidl file, add it to the src directory of the application project, rebuild after creation
2. The Android SDK tool will automatically generate the IBinder interface based on the .aidl file. The specific business object implements this interface. This specific business object is also an IBinder object. When binding the service, it will return the specific interface according to the actual situationWho to communicate with (local or proxy)
3. Bind the client to the service, and then you can call the methods in IBinder for inter-process communication (IPC)
1.3 AIDL communication between two APPs

边栏推荐
猜你喜欢
随机推荐
ImportError: `save_weights` requires h5py.问题解决
基于php旅游网站管理系统获取(php毕业设计)
基于php影视资讯网站管理系统获取(php毕业设计)
基于php在线考试管理系统获取(php毕业设计)
shell编程规范与变量
How to encapsulate the cookie/localStorage sessionStorage hook?
多商户商城系统功能拆解19讲-平台端发票管理
JVM内存结构详解
左旋氧氟沙星/载纳米雄黄磁性/As2O3磁性Fe3O4/三氧化二砷白蛋白纳米球
C陷阱与缺陷 第5章 库函数 5.5 库函数signal
2022-08-01 第五小组 顾祥全 学习笔记 day25-枚举与泛型
FusionGAN:A generative adversarial network for infrared and visible image fusion article study notes
Appendix A printf, varargs and stdarg A.1 printf family of functions
51.【结构体初始化的两种方法】
Flink cluster construction
Spark shuffle调优
sizeof的详细解说和与strlen的区别
分类接口,淘宝分类详情 API
C Pitfalls and Defects Chapter 7 Portability Defects 7.6 Memory Location 0
Appendix A printf, varargs and stdarg A.3 stdarg.h ANSI version of varargs.h









