当前位置:网站首页>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
边栏推荐
猜你喜欢
HCIP---企业网的架构
shell脚本
AI应用第一课:支付宝刷脸登录
Day33 LeetCode
空间数据库开源路,超图+openGauss风起禹贡
Based on php online examination management system acquisition (php graduation design)
一个关于操作数据库的建议—用户密码
基于php动漫周边商城管理系统(php毕业设计)
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.4 K&R C
线上一次JVM FullGC搞得整晚都没睡,彻底崩溃~
随机推荐
基于php酒店在线预定管理系统获取(php毕业设计)
空间数据库开源路,超图+openGauss风起禹贡
C Pitfalls and Defects Chapter 7 Portability Defects 7.8 Size of Random Numbers
2022牛客多校联赛第五场 题解
C Expert Programming Preface
基于php在线学习平台管理系统获取(php毕业设计)
淘宝获取收货地址列表的 API
方舟生存进化是什么游戏?好不好玩
RecycleView的使用
图像融合GANMcC学习笔记
Upload markdown documents to blog garden
with语句和上下文管理器
【Jmeter常用断言组件】
包含吲哚菁绿的多聚体白蛋白纳米球/载马钱子碱纳米粒的牛血清白蛋白微球的制备
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.3 The Standard I/O Library and the C Preprocessor
Image fusion GANMcC study notes
ImportError: `save_weights` requires h5py.问题解决
LeetCode·32.最长有效括号·栈·动态规划
Interview Blitz 70: What are sticky packs and half packs?How to deal with it?
LeetCode