Stating Your Intent(ions)

 

All Android components that wish to be notified via intents must declare intent filters, so Android knows which intents should go to that component. To do this, you need to add elements to your file.

All of the example projects have intent filters defined, courtesy of the Android application‑building script ( or the IDE equivalent). They look something like this:

 

Note the element under the element. Here, we declare that this activity:

• is the main activity for this application

• is in the category, meaning it gets an icon in the Android main menu

Because this activity is the main one for the application, Android knows this is the component it should launch when somebody chooses the application from the main menu.

You are welcome to have more than one action or more than one category in your intent filters. That indicates that the associated component (e.g., activity) handles multiple different sorts of intents.

More than likely, you will also want to have your secondary (non‑MAIN) activities specify the MIME type of data they work on. Then, if an intent is targeted for that MIME type – either directly, or indirectly by the Uri referencing something of that type – Android will know that the component handles such data.

For example, you could have an activity declared like this:

 

This activity will get launched by an intent requesting to view a representing a piece of content. That intent could come from another activity in the same application (e.g., the MAIN activity for this application) or from another activity in another Android application that happens to know a that this activity handles.

 








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


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

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

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

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