Make the Call

 

Once you have your , you need to pass it to Android and get the child activity to launch. You have four choices:

• The simplest option is to call with the – this will cause Android to find the best‑match activity and pass the to it for handling. Your activity will not be informed when the “child” activity is complete.

• You can call , passing it the and a number (unique to the calling activity). Android will find the best‑match activity and pass the over to it. However, your activity will be notified when the child activity is complete via the callback (see the text following this list).

• You can call . In this case, Android will pass the to all registered that could possibly want this Intent, not just the best match.

• You can call . Here Android will pass the to all candidate one at a time – if any one “consumes” the , the rest of the candidates are not notified.

Most of the time, you will wind up using or – broadcast are more typically raised by the Android system itself.

With , as noted, you can implement the callback to be notified when the child activity has completed its work. The callback receives the unique number supplied to , so you can determine which child activity is the one that has completed. You also get the following:

• A result code from the child activity calling . Typically this is or , though you can create your own return codes (pick a number starting with ).

• An optional containing some result data, possibly a URL to some internal or external resource – for example, an typically returns the selected bit of content via this data string.

• An optional containing additional information beyond the result code and data string.

To demonstrate launching a peer activity, take a peek at the sample application in the Source Code section at http://apress.com. The XML layout is fairly straightforward: two fields for the latitude and longitude, plus a button:

 

The button’s simply takes the latitude and longitude, pours them into a scheme , then starts the activity.








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


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

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

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

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