【问题标题】:Send an Intent from a foreground Activity to another one without closing it将 Intent 从前台 Activity 发送到另一个而不关闭它
【发布时间】:2011-09-11 13:34:06
【问题描述】:
我想将一些数据从前台活动传递到当前在后台的另一个活动。
我知道我可以使用 setResult()/onActivityResult() 和 startActivity()/getIntent() 在 Activity 打开/关闭时发送带有数据的 Intent,但在这种情况下,这似乎不可用。
除了使用静态方法或字段,还有什么办法吗?
【问题讨论】:
标签:
android
android-activity
android-intent
【解决方案1】:
您可以使用 sharedpreferences 来存储数据
【解决方案2】:
我没有做你想做的事,但我想你可能想调查处理程序和消息传递......
【解决方案3】:
BroadcastReceiver(在 onCreate 中注册并在 onDestroy 中取消注册)正是我想要的。