java - 实例化重复警报后如何从 BroadcastReceiver 与 Activity 通信

标签 java android broadcastreceiver android-intent alarmmanager

我正在创建一个循环警报,我希望它能够与调用它的 Activity 进行通信。我可以将 Intent 数据发送到 BroadcastReceiver 但在 BroadcastReceiver 运行时从 Activity 获取信息目前还不清楚。我需要 BroadcastReceiver 从调用它的 Activity 中轮询信息。

最佳答案

I am creating a recurring alarm, which I want to be able to communicate with the Activity that called it.

很可能“调用它的 Activity”不再存在,因为它已被销毁。

I need the BroadcastReceiver to poll information from the Activity that called it.

不,你不知道。您需要您的 Activity 和您的 BroadcastReceiver 来使用共享的持久数据模型,例如数据库或文件,可能通过静态数据成员进行缓存。

关于java - 实例化重复警报后如何从 BroadcastReceiver 与 Activity 通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7142007/

相关文章:

java - 静态资源+web-inf+Spring Boot

java - Monodroid Java 绑定(bind)

java - 通过线程名称杀死一个java线程

java - Sonar 3.7 : Unable to execute wih maven

java - 开始 Activity/收集数据/销毁

java - ORMLite 混合 orderBy() 和 orderByRaw()

android - 带有 ImageView 和 TextView 的 SimpleCursorAdapter

android - 如何在代码中使用工作管理器-Android

android - 没有 UI 的 Activity

java - Android - 创建后台服务以接收 PubNub 消息