简体   繁体   English

如何将参数从调用服务的活动传递到广播接收器

[英]How to pass argument to broadcast receiver from an activity that call a service

Hey I want to pass an argument to the broadcast receiver. 嘿,我想把一个论点传递给广播接收器。 Here is the scenario: In an activity when i press a button it will call a service that service will call BroadCastReceiver. 这是场景:在一个活动中,当我按下一个按钮时,它将调用一个服务,该服务将调用BroadCastReceiver。 Now i want to pass a parameter from the activity to service which will in turn pass same data to the BroadCastreceiver 现在我想将参数从活动传递到服务,这又会将相同的数据传递给BroadCastreceiver

Is it possible...? 可能吗...?

Pass it using the intent that you use to start the service. 使用您用于启动服务的意图来传递它。

Incidentally, what do you mean by "call the broadcast receiver?" 顺便说一句,“呼叫广播接收机”是什么意思? You should never directly call a Broadcast Receiver - they're just for handling broadcasts (events). 您永远不应直接致电广播接收器-它们仅用于处理广播(事件)。 With that said, if you're just sending a broadcast, you can include the data in that intent. 话虽如此,如果您只是发送广播,则可以将数据包含在该意图中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM