views:

56

answers:

2

Is there a way that a Service can report back to the calling activity when the Service has reached a particular stage of processing?

For eg: Consider a music player activity that initiates the actual music playing in the background as an Android Service. I want to detect and inform the Activity when the Service has reached the Mediaplayer's onPrepared. Is there a way that the Service can tell the calling Activity when the MediaPlayer's onPrepared is called, to let the Activity know that the audio is prepared and ready to play?

I am basically looking to see if there is work around, rather than having a thread in the activity, pinging constantly to check if the Service has reached onPrepared.

Thanks Chris

A: 

You can always use interfaces to communicate between activitie(s) and service. Right after you have connected to the service you set your interface to it and if service gets to some state that you want it to communicate back to the activity you just call out the appropriate method for it.

motoklamber
A: 

You can pass interfaces as parceables in your launch Intent. Check the source for Google I/O 2010 app like this question.

alexanderblom