Pieces of Intents

 

The two most important pieces of an intent are the action and what Android refers to as the “data”. These are almost exactly analogous to HTTP verbs and URLs – the action is the verb, and the “data” is a , such as representing a contact in the contacts database. Actions are constants, such as (to bring up a viewer for the resource), (to edit the resource), or (to choose an available item given Uri representing a collection, such as ).

If you to create an intent combining with a content of , and pass that intent to Android, Android would know to find and open an activity capable of viewing that resource.

There are other criteria you can place inside an intent (represented as an Intent object), besides the action and “data” , such as:

• A category. Your “main” activity will be in the category, indicating it should show up on the launcher menu. Other activities will probably be in the or categories.

• A MIME type, indicating the type of resource you want to operate on, if you don’t know a collection .

• A component, which is to say, the class of the activity that is supposed to receive this intent. Using components this way obviates the need for the other properties of the intent. However, it does make the intent more fragile, as it assumes specific implementations.

• “Extras”, which is a Bundle of other information you want to pass along to the receiver with the intent, that the receiver might want to take advantage of. What pieces of information a given receiver can use is up to the receiver and (hopefully) is well‑documented.

You will find rosters of the standard actions and categories in the Android SDK documentation for the Intent class.

 








Дата добавления: 2015-05-16; просмотров: 698;


Поиск по сайту:

При помощи поиска вы сможете найти нужную вам информацию.

Поделитесь с друзьями:

Если вам перенёс пользу информационный материал, или помог в учебе – поделитесь этим сайтом с друзьями и знакомыми.
helpiks.org - Хелпикс.Орг - 2014-2024 год. Материал сайта представляется для ознакомительного и учебного использования. | Поддержка
Генерация страницы за: 0.003 сек.