Alan Kazbekov
Alan Kazbekov

Reputation: 1157

How to distribute custom classes for clients when writing Android service with AIDL

I'm writing Android service application. Clients bind to service and then invoke remote functions (interface generated with AIDL) and get back results. I know I can use objects of arbitrary class (inherited from Parcelable and implementing Creator interface) as arguments or a return value. Client and service must use the same "interface arguments" classes. The question is how to publish and distribute .aidl files and such a "shared" class set to clients? This classes must be a part of public API. The only way I see is to make a "dependency" library with all classes used by client and server, and let clients to use it in their projects. Is this a common approach?

Upvotes: 3

Views: 254

Answers (1)

sergej shafarenka
sergej shafarenka

Reputation: 20426

The only way I see is to make a "dependency" library with all classes used by client and server, and let clients to use it in their projects. Is this a common approach?

Right. Just pack all classes and your AIDL file into that library to give it to your clients. The only thing which clients need to do in addition is to put a copy of your AIDL file into their projects, that a service proxy implementation can be built.

Google does it for their In-app Billing library. Here is a description of how they recommend to use it.

Upvotes: 2

Related Questions