What is the point of defining actions within intent filters on a reciever tag
I'm currently exploring Broadcast Receivers and Broadcast Intent. There are some aspects of the tutorials which are ambiguous to me. To my know开发者_开发百科ledge this is how the process works. I can broadcast an intent from my application and any receiver on the phone can act on that intent as long as the actions match. I can register a broadcaster receiver on anything that extends Context and when I do so I must provide a filter which will allow the receiver to act on one or more intent actions.
The part which confuses me is defining a receiver via the manifest. Must the name of said receiver match a class name? Why should I ever define an intent filter with an action in the project manifest if I always have to provide another intent filter when I register my receiver in code?
If anyone has a good tutorial or example of the best way to use broadcast receivers and how I should define them I would appreciate it.
I cant broadcast an intent from my application and any receiver on the phone can act on that intent as long as the actions match.
Yes, you can.
Must the name of said receiver match a class name?
Yes, because that is the class that implements the BroadcastReceiver
.
Why should I ever define an intent filter with an action if whenever I register a receiver I have to provide an intent filter?
That sentence makes no sense.
Here are some examples of projects using manifest-registered BroadcastReceivers
whose <intent-filter>
filters on an action.
精彩评论