How to implement callbacks using IntentService on Android?

后端 未结 2 1512
一生所求
一生所求 2021-01-14 01:09

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

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

2条回答
  •  执笔经年
    2021-01-14 02:15

    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.

提交回复
热议问题