I have an Activity that starts a local Service for background operation.
They both resides on the same process, so the communication between them should be simpler.
However, I don't understand how to implement the communication according to my needs:
Activity's behavior:
On creation, check if the service is already running:
- If it is already running, disable Start button, and enable Stop button.
- Otherwise, enable Start button, and disable stop button.
- When Start button pressed: start the service, and wait for notification from the service that it finished its internal initialization. (can take more than 10 seconds)
- When Stop button pressed: stop the service.
My problem is how to make the Activity listen to the Service without busy-waiting.
I could use IBinder according to this link, but I will have to busy-wait.
I will be glad for suggestions.