I need to find out which broadcast receivers can handle a given Intent.
It seems that queryBroadcastReceivers() does not return receivers registered in code using registerReceiver() but only receivers declared in AndroidManifest.xml.
Is this behavior by design?
Any other way to find all installed receivers for some Intent ?
Thanks.
It looks like it's not possible to detect receivers registered in code, as per this recent message on the mailing list: http://groups.google.com/group/android-developers/msg/5fd1cdb24b2a6760
This is disappointing as I was looking for a way to do the same thing.
If the receivers you're interested in are yours, you can use sendOrderedBroadcast instead of regular broadcast.
This makes the broadcast goes to all registered receivers one by one, according to priority, and finally to your supplied broadcast receiver, which according to the result/data passed to it, can figure out which receivers handled this before it.
You can check this example project which uses this method: http://www.mannaz.at/codebase/android-activity-foreground-surveillance/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With