开发者

Give access to an Android service without giving the sources

开发者 https://www.devze.com 2023-04-10 09:02 出处:网络
I am creating an Android service that my own app will use, but I also want it to be available to external apps.

I am creating an Android service that my own app will use, but I also want it to be available to external apps.

The service is decla开发者_Go百科red using AIDL files.

I have two separate projects, one for the service, one for the application. In Eclipse I reference the service project in the application project to have access to the generated classes from the AIDL files, which works fine.

But now, I want to give access to the service to other apps, how do I do it? Should I distribute the AIDL files? The class files? Each project will have to copy my AIDL files into their eclipse project?

What if I change the signature of a method of the service?

Thanks


If you expect third parties to access your service you must provide some form of interface for them. This would be AIDL in this case. So you will have to distribute it and service consumers will have to use it. Most likely they will have to include it in their project.

If you change signature, they will have to update their code. This is a typical problem in similar cases - welcome to the club! You would need to version your interface definition in some form and then either block incompatible clients or provide some conversion layer so they access your new service using old interface.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号