Sprucing Up Your Home

 

Android 1.5 lets you do more with the built‑in home screen application, notably by adding “app widgets” and “live folders”. As an application developer, you can choose to offer app widgets and/or live folders from your own applications for users to add to their home screens.

App widgets are simply user interface elements added to the home screen. Previous Android editions had some of these (the analog clock, the Google search bar), but they were fixed in type and number. Now, not only does Android add in a couple of more app widgets (e.g., media player, picture frame), but users can add and remove app widgets, and developers can create their own (see Figure A‑2).

Figure A‑2. Some stock Android 1.5 app widgets

App widgets are built not using ordinary layouts, but rather with a layout subset known as . You cannot use arbitrary widgets with , though it supports many common ones. The term “remote views” comes from the fact that while the UI is defined by your application, the UI (in the form of the “app widget”) runs in the context of another application, in this case the home screen.

Implementing an app widget involves creating some XML metadata, associating that metadata with a element in your manifest, and implementing that receiver as an . Most likely in conjunction with a service that will handle any time‑consuming work (e.g., network lookups), your provider will create and push out when requested by the home screen. Note that app widgets are designed for infrequent update, since frequent polling for new widget contents can rapidly drain the device battery.

Live folders are, in essence, a simplified home‑screen‑launched look into the contents published by a . In the screenshot shown previously, you see a “Phones” icon. Tapping that brings up a dialog over the home screen containing a list of all contacts containing phone numbers as you can see in Figure A‑3.

Figure A‑3. A Live Folder in Android 1.5

Tapping an individual contact, of course, brings up the detail screen for that contact.

To create your own live folders for your users to offer, you can add an intent filter watching for a on an activity in your application. That activity, in turn, simply calls with another object, this one describing the live folder, such as its icon, name, and display mode (e.g., ). This also contains the pointing to the whose information you are trying to display. That should be updated to recognize the live folder and, on , return an ID, title, and description of each piece of content in the provider (or a subset if appropriate). Android will take care of the rest, in terms of formatting the data in the live folder convention (large font title, small font description), pouring the query results into a list, etc.

 








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


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

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

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

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