Entertaining the Client

 

If you are going to use the as a local user interface (vs. browsing the Web), you will want to be able to get control at key times, particularly when users click on links. You will want to make sure those links are handled properly, either by loading your own content back into the , by submitting an Intent to Android to open the URL in a full browser, or by some other means (see Chapter 25).

Your hook into the activity is via , which takes an instance of a implementation as a parameter. The supplied callback object will be notified of a wide range of activities, ranging from when parts of a page have been retrieved (, etc.) to when you, as the host application, need to handle certain user‑or circumstance‑initiated events, such as and , etc.

A common hook will be , where your callback is passed a URL (plus the itself) and you return true if you will handle the request or if you want default handling (e.g., actually fetch the Web page referenced by the URL). In the case of a feed reader application, for example, you will probably not have a full browser with navigation built into your reader, so if the user clicks a URL, you probably want to use an to ask Android to load that page in a full browser. But, if you have inserted a “fake” URL into the HTML, representing a link to some activity‑provided content, you can update the yourself.

For example, let’s amend the first browser example to be a browser‑based equivalent of our original example: an application that, upon a click, shows the current time.

From , here is the revised Java:








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


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

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

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

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