AIDL是什么
AIDL的全称为 Android Interface definition language 是android接口定义语言。
他的好处是什么 : 进程间通讯 通过 bindService将ServiceConnection进行绑定连接,调用其它线程的功能。
@Override
public boolean bindService(Intent service, ServiceConnection conn,
int flags) {
return mBase.bindService(service, conn, flags);
}
为什么要知道AIDL
AIDL在我们的应用中极少见,但是在framwork层中却是非常普通寻常的东西。所以想更好的学习framwork的话首先得搞懂AIDL.
AIDL的基本用法。
首先我们在客服端要创建.aidl文件。
第一步:在android studio 工程中new ->AIDL->AIDL File 便可创建出一个.aidl文件命名为IServise.aidl当然这个名字自己随便取但一定要以I开头。如下:
然后再再.aidl文件中写自己需要调用的方法。如下:
// IServise.aidl
package com.example.yuchao.hellohaha;
// Declare any non-default types here with import statements
interface IServise

本文介绍了Android Interface Definition Language (AIDL),用于实现进程间通信。讲解了AIDL的重要性,以及如何在Android Studio中创建和使用AIDL,包括创建.aidl文件、生成对应的Java文件、在Service中声明意图、处理Android 5.0后的Intent问题等关键步骤。
5284

被折叠的 条评论
为什么被折叠?



