How To Establish A Two-way Communication Between Activity And Service In Different Process?
I'm working on establishing a two-way communication between an Activity and a Service which runs in a different process. Querying the process from the Activity is no big deal. But
Solution 1:
Either use BroadcastReceiver
or have the Activity
register a callback or listener object that the Service
calls on key events. The links above are to book example projects demonstrating each of those techniques.
Solution 2:
I think you should have the BroadcastReceiver
start your activity again with the result in the Intent.
Or you could use AIDL about AIDL. The samples also have an (multiple?) example how to use AIDL and services. But AIDL
might be to much of a hassle for your purpose.
Solution 3:
You have to use BroadcastReceiver
to receive intents, and when you want to communicate simply make an Intent with appropriate values.
This way you should be able to make a 2-way communication between any component.
Post a Comment for "How To Establish A Two-way Communication Between Activity And Service In Different Process?"