AIDL interface between two applications

与世无争的帅哥 提交于 2019-12-01 00:11:52

I decided to answer my own question since I found an exact solution.

My Life With Android

Everything worked just by copy pasting the source and changing the package names and function names correctly (assuming you're implementing this into your own project)

Source from client folder goes to the client activity and serviceimpl goes to service. I didn't need the 'Service activity', so I left it out ( and it doesn't really seem to be invoked anyway).

I don't have enough reputation to post multiple links, so you can get the source from the top of the page.

"Update: please check out the updated example program for Android SDK 1.5."

I struggled with this too. You are correct in your guess that the RemoteInterface.aidl needs to have the same package name in both the service and the test app - so where do you put it!?

If you are developing in Eclipse then the trick is to have a common source folder (common to both projects) Make this folder outside of both projects and in the build properties/source, click 'link source' and browse to the location of the common source. (You can call it any name you want) Do this in both projects and put the interface.aidl in there. It will appear in both projects' Package Explorer and when you change it in one project, the other will get updated too.

In the common source folder I put the interface.aidl in a package with the same name as the service.

If you are using Ant to build, the it gets a bit tricky as the default ant_rules.xml doesn't support two aidl folders, and you'll have to modify your build.xml quite a bit add a new target and all its dependencies.

I got my project going by adapting the samples form Chapter 17 from the 'download source' here:

link text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!