如何在Android上使用IntentService实现回调?
是否必须用AIDL来实现? 请提供一个例子,谢谢。
编辑: 有几种解决方案,有人知道哪个更好吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否必须用AIDL来实现? 请提供一个例子,谢谢。
编辑: 有几种解决方案,有人知道哪个更好吗?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
您可能正在寻找
ResultReceiver
类 (http:// /developer.android.com/reference/android/os/ResultReceiver.html)。您扩展它,将其与您调用
Service
的意图一起传递(它是可打包的),然后当您的任务在Service
中完成时,您调用 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 theService
, you call the ResultReceiver'sonReceiveResult()
method with the results.查看这篇文章:在 Android 中使用 ResultReceiver ,讨论 resutlreceiver 的实现。
checkout this post :Using ResultReceiver in Android , discussing the implementation of resutlreceiver.