android - Activity 和服务之间的通信

标签 android commonsware

在 commonsware 4.0 一书的第 550 页,Messenger进行了讨论,并解释了 Activity 如何在启动服务时附加额外数据,从而允许服务在需要时随时将消息发送回 Activity。

然后它解释了服务如何在需要时随时将数据发送回 Activity。

我已在我的应用中实现并正在运行。

但是我需要让 Activity 在其他场合与服务对话——在 Activity 的生命周期中多次。什么工具或管道允许服务在需要时随时向 Activity 发送消息?

谢谢,加里

最佳答案

What tool or conduit allows the service to send messages to the Activity any time it wants?

你自己承认:

It then explains how the service can send data back to the Activity anytime it wants.

因此,您的答案是 Messenger。或该章中概述的任何其他技术。

关于android - Activity 和服务之间的通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13213869/

相关文章:

Android缩小相机图片的大小

android - 小部件点击不起作用?

java - android中已弃用类的现有等价物

java - android 使用数组从 url 共享图像?

android - 通过 inflate 从合并布局到 RelativeLayout 的 XML 属性

android - 自动链接不适用于 HTC - HtcLinkifyDispatcher

java - 如何向 PDF 文件添加限制,使其被锁定且无法编辑或复制内容,最好使用 Ghostscript 或 Java?

java - 如何像此应用程序中那样保持 ImageView 的纵横比? [Android,ImageView,长宽比,ScrollView]

android - 如何将QCAR(Vuforia)的投影和模型 View 矩阵应用到min3D场景中