Android AIDL Concept
-
Upload
charile-tsai -
Category
Software
-
view
371 -
download
6
Transcript of Android AIDL Concept
Android AIDL ConceptCharlie Tsai @ Android Study Group
Agenda
• Introduction of AIDL• Write your AIDL files• Implementation of AIDL
Introduction of AIDL
?AIDL?• Android Interface Definition Language• Main approach is IPC (Inter-Process
Communication)• Support types:
All primitive types, CharSequence & String, List & Map, Parcelable class
IPC Issue
Memories of Process A
Process B of Process BX
Cannot Access(Memory protection
by Kernel)
How AIDL solve IPC issue
Memories of Process A
Process B of Process B
Linux Kernel & Binder Driver
Access Access
Write Your AIDL File• Write *.aidl for your AIDL interface• You can turn your Parcelable Class into
AIDL• Include if you use Other AIDL
class/interface• Note:
List will become ArrayList in another sideMap will become HashMap in another side(WHY?)
AIDL Data StructureMyData.java
MyData.aidl
AIDL InterfaceIMyAidlInterface.aidl
How Parcelable Work
Stringint
Data in memory(order is matter)
Usages of AIDL
Export Your ServiceAllow to be bound
by other App.
Use Other’s ServiceCopy *.aidl file into your project
(Because you need to know this Interface)
Generated File by AIDL
• IInterface: Basic interface can be used for IPC• android.os.IBinder: Core class of IPC• Use YourInterface.asInterface(IBinder) to case
IBinder to YourInterface.• Use IBinder.queryLocalInterface() to know if this
IBinder is in local or remote.• If IBinder is in local, call function directly.• If IBinder is a remote object, use transact and
parcel to call function.
Let’s see the source code…
Questions?
固定聚會:每週三@果子咖啡 (近捷運南京復興站 )技術分享:每月底週六 14:30 - 17:30以及眾多不定期活動 (ex: Workshop)
Thanks!