How to implement callbacks using IntentService on Android?

shiami picture shiami · Oct 13, 2010 · Viewed 8.3k times · Source

If it must implement with AIDL? And please kindly provide an example, thanks.

EDIT: There are several solutions, Does anyone know which is better?

Answer

Zsombor Erdődy-Nagy picture Zsombor Erdődy-Nagy · Oct 13, 2010

You might be looking for the ResultReceiver class (http://developer.android.com/reference/android/os/ResultReceiver.html).
You extend it, pass it along with the intent you invoke the Service with (it's parcelable), then when your task completes in the Service, you call the ResultReceiver's onReceiveResult() method with the results.