I am developing an android application that runs a service off the main thread. It then runs another activity that exists in a seperate apk file. This apk needs to be able to spawn its own service and exchange information (complex objects) with the original service. They both share both serv开发者_运维知识库ices if that helps, as the services exist in a android library that both apk's reference. Is there any way to achieve this functionality? What are the limitations involved and is there any way they can be overcome.
For Service 2 to communicate with Service 1 both have to be written by you. If by 'the services exist in a android library that both apk's reference' you mean its an android system service then I don't think this would be possible unless you override the service definition.
If at all you are using android system services, you could try having a broadcast receiver in your Service 1 that is notified of all updates Service 2 may publish.
If the apps 1,2 and services 1,2 are all written by you then I do not think this is that difficult to achieve as you can share data using bundles in intents.
精彩评论