Peers and Subs

 

One key question you need to answer when you decide to launch an activity is, does your activity need to know when the launched activity ends?

For example, suppose you want to spawn an activity to collect authentication information for some Web service you are connecting to – maybe you need to authenticate with OpenID[26] in order to use an OAuth[27]service. In this case, your main activity will need to know when the authentication is complete so it can start to use the Web service.

In this case the launched activity is clearly subordinate to the launching activity. Therefore you probably want to launch the child as a sub‑activity, which means your activity will be notified when the child activity is complete.

On the other hand, imagine an email application in Android. When the user elects to view an attachment, neither you nor the user necessarily expects the main activity to know when the user is done viewing that attachment.

In this scenario, the launched activity is more a peer of your activity, so you probably want to launch the “child” just as a regular activity. Your activity will not be informed when the “child” is done, but, then again, your activity really doesn’t need to know.

 

Start ’Em Up

 

The two requirements for starting an activity are an Intent and your choice of how to start it up.

 








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


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

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

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

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