GetData

 

 

The result: the user chooses a collection (Figure 25‑1), picks a piece of content (Figure 25‑2), and views it (Figure 25‑3).

Figure 25‑1. The PickDemo sample application, as initially launched

Figure 25‑2. The same application, after the user has clicked the Gimme! button, showing the list of available people

Figure 25‑3. A view of a contact, launched by PickDemo after the user has chosen one of the people from the pick list

 

Would You Like to See the Menu?

 

Another way to give the user ways to take actions on a piece of content, without you knowing what actions are possible, is to inject a set of menu choices into the options menu via . This method, available on , takes an and other parameters and fills in a set of menu choices on the Menu instance, each representing one possible action. Choosing one of those menu choices spawns the associated activity.

The canonical example of using illustrates another flavor of having a piece of content and not knowing the actions that can be taken. In the previous example, showing , the content was from some other Android application, and we know nothing about it. It is also possible, though, that we know full well what the content is – it’s ours. However, Android applications are perfectly capable of adding new actions to existing content types, so even though you wrote your application and know what you expect to be done with your content, there may be other options you are unaware of that are available to users.

For example, imagine the tagging sub‑system mentioned in the introduction to this chapter. It would be very annoying to users if every time they wanted to tag a piece of content, they had to go to a separate tagging tool then turn around and pick the content they just had been working on (if that is even technically possible) before associating tags with it. Instead they would probably prefer a menu choice in the content’s own “home” activity where they can indicate they want to tag it, which leads them to the set‑a‑tag activity and tells that activity what content should get tagged.

To accomplish this, the tagging sub‑system should set up an Intent filter, supporting any piece of content with its own action (e.g., ) and a category of , which is the convention for one application adding actions to another application’s content.

If you want to write activities that are aware of possible add‑ons like tagging, you should use to add those add‑ons’ actions to your options menu, such as the following:








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


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

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

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

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