简体   繁体   English

查找已向registerReceiver()注册的广播接收器

[英]Finding Broadcast Receivers that have been registered with registerReceiver()

I'm trying to find out if there is a broadcast receiver already set up to receive certain intents. 我试图找出是否已经设置了广播接收器来接收某些意图。 (NOTE: These will be in different applications so I can't just keep track, I need a more dynamic solution.) (注意:它们将在不同的应用程序中,所以我不能随便跟踪,我需要一个更具动态性的解决方案。)

I already know that the packageManager.querybroadcastreceiver() will not find these. 我已经知道packageManager.querybroadcastreceiver()找不到这些。

Is there any other way that I might be able to do so? 我还有其他方法可以这样做吗? Can I check to see if my Intent was received? 我可以检查是否收到我的意图吗?

The last thing I want to do is to use a timer.... 我想做的最后一件事是使用计时器。

If you control all those receivers yourself, or can force some behavior on them you can try using the sendOrderedBroadcast method. 如果您自己控制所有这些接收者,或者可以对它们强制采取某些行为,则可以尝试使用sendOrderedBroadcast方法。 Note that you can define a "resultReceiver" which will be called after all the other receivers will be called. 注意,您可以定义一个“ resultReceiver”,在所有其他接收器都将被调用之后将被调用。

So if you can force the other receivers to behave in a certain way, you can change the resultCode or even abort the broadcast when they get the intent, and that way in your resultReceiver you will be able to tell if others were called 因此,如果您可以强制其他接收者以某种方式运行,则可以更改resultCode甚至在他们收到意图时中止广播,这样,在resultReceiver中,您就可以知道是否调用了其他接收者

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

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