Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Example of AIDL use

Tags:

android

aidl

People also ask

Where is AIDL used?

AIDL is used for Binder. Binder is a mechanism to do RPC calls on/from an Android Service.

What data types are supported by AIDL?

all native Java data types like int,long, char and Boolean.

What is an AIDL file?

An AIDL file is used by Android app developers to enable communication between different apps. It contains Java source code that defines an interface, or contract, for how apps can communicate with each other. AIDL is an implementation of the Interprocess Communication (IPC) protocol provided by Android.

How does AIDL work on Android?

The Android Interface Definition Language (AIDL) is a tool that lets users abstract away IPC. Given an interface (specified in a . aidl file), various build systems use the aidl binary to construct C++ or Java bindings so that this interface can be used across processes, regardless of the runtime or bitness there.


AIDL is used for Binder. Binder is a mechanism to do RPC calls on/from an Android Service.

When to use AIDL? When you need a Service. When do you need a Service? If you want to share data and control something in another application, you need a service using AIDL as an interface. (A Content Provider is used when sharing data only).

Services can be used within your application as the model roll in the MVC-pattern.


AIDL is Android Interface Definition Language. This basically allows you to do IPC calls.

Use: There are situations where one process would need to talk to other to obtain certain information.

Example: Process A needs info of Call status to determine whether it needs to change Call Type (for example Audio to Video Call or Vice-versa). You may get call status from certain listeners but to change Call type from Audio to Video, Process A needs a hook to change. This "Hook" or way of changing calls is typically part of Telephony Classes which are part of Telephony Process. So in order to obtain such an information from Telephony process, One may write a telephony service (which runs as a part of android telephony process), which will allow you to query or change call type. Since Process A(Client) here is using this remote Service which communicates with Telephony process to alter call type, it needs to have an interface to talk to service. Since Telephony service is the provider, and Process A (client) is the user, they both need to agree on an interface (protocol) they can understand and adhere to. Such an interface is AIDL, which allows you to talk (via a remote service) to Telephony process and get some work done.

Simply put in laymen terms, AIDL is an "agreement" Client gets, which tells it about how to talk to service. Service itself will have a copy of that agreement(since it published for it's clients). Service will then implement details on how it handles once a request arrives or say when someone is talking to it

So process A requests to change call via Service, Service gets the request, it talks to telephony process(since it's part of it) and changes call to video.

An important point to note is, AIDL is only necessary for multithreading environment. You could do away with Binders if you don't need to deal with multithreaded arch.


Another real world example is Google Play License is using AIDL.