问题
To generalize, I understand my application can declare activities to handle specific intents (filtered by category and actions). I can declare my app to handle the ACTION_VIEW and somehow have it magically be registered as a browser to the system. How is this done? Is there a resource that anyone knows of to further read into how which action/category combination lets apps register themselves to the system as, say, browsers?
Specifically, I'm wondering how I would be able to register my application as a handler for the message waiting indicator notification, so that if tapped from the notification bar, my app would be chosen to "Complete action with..."
The only intent actions I can find, relating to voicemail/MWI, would be ACTION_DIAL, but I'm looking to open my app when the MWI is tapped from the notification bar.
回答1:
To be honest, I have been trying to get a Intent database that developers can post their own Intents (of course, that they have to have ways to make sure people don't abuse it).
The way you specify an intent is in the manifest that you specify the action (action_view, etc) and a prefix you want to catch, say "http://", and then it will get registered when the application is installed. It will get called when the category, action, prefix and other data matches base on the specific intent.
To receive a intent, such as the one you are trying to do, you will have to register a "receiver" class on your manifest. It will be called when the intent gets broadcasted.
Not all the actions can be listened. and I am not sure if a broadcast is sent when the indicator notification is tabbed. You will have to look at the Android source code to figure that out. Or maybe Google will help you out. But I think it is not likely that the tab action will trigger an intent broadcast.
Good Luck!
来源:https://stackoverflow.com/questions/7013194/clarification-on-intents-context-and-overriding-default-behaviour