如何实现在Android上使用IntentService回调?回调、如何实现、Android、IntentService

2023-09-08 08:38:33 作者:便秘时想起你

如果它必须与AIDL实现?并请您提供一个例子,谢谢。

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

编辑:有几种解决方案,有谁知道哪个好?

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

推荐答案

您可能会寻找ResultReceiver类(http://developer.android.com/reference/android/os/ResultReceiver.html)。你扩展它,通过它的意图以及在调用服务与(这是parcelable),那么当你的任务在服务完成后,您拨打ResultReceiver的onReceiveResult()方法的结果。

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.