如何实现在Android上使用IntentService回调? [英] How to implement callbacks using IntentService on Android?

查看:440
本文介绍了如何实现在Android上使用IntentService回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果它必须与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.

这篇关于如何实现在Android上使用IntentService回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆