Intent makes the Android’s heart bitting

by Philip Barlow / from beautifuldecay.com

Intent can be something like “I want to search a contact register” or “Open this web site” or “Show me the purchase confirmation screen”. It can be a specific or generic  description of what you want done. Intent makes the Android’s heart bitting

One of advantages of intent is the capacity of call and use screens and functions of others applications instead of develop and maintain what you want. Followed by importance of Intents when it makes the navigation easy in a innovative way because of possibility to inform a vague and not specific want and wait some application that responds it, featuring a weak coupling with the function that will realise it.

An Intent can be composed by an action, that describes what you want to do, a data, that is a name of what you want to request in a URI format, a category, that informs where and how the intent can be used, a bundle of extras arguments, a type, that informs the explicit MIME type and the component, if the developer wants to refer a specific class or package (explicit invocation) to receive the intent.

How the OS knows which application can deal with my Intent?

The OS will search for an application that has an IntentFilter that matches with the Intent released. An IntentFilter is declared at Android manifest file:

How Does this match happen?

An IntentFilter can specify zero or more actions and zero or more categories. If any action is specified in the IntentFilter, it will match with any Intent.Otherwise, it only will match with an Intent that has the same action.

And…What does happen if two or more IntentFilter match with my Intent?

For an intent of realise something visual, as opening an Activity, the OS will offer the possibility of choise in a pop-up menu which application that the user want to deal with the intent. For an invisible action, like invoke an broadcast, the OS will offer the possibility for all these applications deal with the Intent, ordening by the priority of IntentFilter.

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair /  Alterar )

Foto do Google+

Você está comentando utilizando sua conta Google+. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

w

Conectando a %s