Reputation: 1295
I'm currently a junior developer. I've heard about IPC and now I'm learning about Android AIDL.
I've made an .aidl
file, I've implemented the methods from that .aidl
in a Service and I've used those methods in another application, but I don't see the point.
Why I cannot just make an .aar
or a .jar
file containing that Service, without using AIDL? When I should use AIDL and when I should import .jar
files. More general, what is the point of using IPC when we can work with .jar
files?
Upvotes: 1
Views: 1452
Reputation: 3852
Why I cannot just make an .aar or a .jar file containing that Service, without using AIDL?
From documentation https://developer.android.com/guide/components/aidl.html:
Using AIDL is necessary only if you allow clients from different applications to access your service for IPC and want to handle multithreading in your service.
When you pack a Service
in aar or jar this service can run anywhere, i.e. either in the same or in a different process of an application. AIDL is specifically designed for IPC, that is, service and app in different processes.
More general, what is the point of using IPC when we can work with .jar files?
IPC is a operating system provided data sharing mechanism and jar is a bytecode distribution means. They are different things.
Suppose you want to consume a service provided by someone, and that you don't have its source nor its bytecode. You can only access this service in runtime, in a process managed by the provider, different than your own. In this case you'll need an AIDL specified by the provider in order to communicate with the service.
Upvotes: 4