Update a running BroadcastReceiver (passing new values) and Activity

Is it possible to update a currently running Broadcastreceiver from an Activity? For example:

Say the user enters a string…and then hits submit…I want the broadcast receiver to be updated with the new string and use that string instead of an older one that the receiver may have. Is this possible? Or can I somehow stop the old receiver when the user clicks submit and then restart it with the new string?

Maybe I misunderstood your question but why not storing your string in a SharedPreference
?

Whenever you Activity will need to update that string, it will save it as preference and on the onReceive
method of your broadcastreceiver, you just get it back from the preference.

Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 移动开发 » Update a running BroadcastReceiver (passing new values) and Activity

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录