AIDL interface between two applications

前端 未结 2 1717
别跟我提以往
别跟我提以往 2021-01-06 20:25

I\'ve stuck a total wall with the AIDL interfacing. I\'ve an app which has to be controlled via 3rd party application (I\'ve enough control over this so I can ask them to im

相关标签:
2条回答
  • 2021-01-06 20:50

    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

    0 讨论(0)
  • 2021-01-06 20:53

    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."

    0 讨论(0)
提交回复
热议问题