App Widgets are miniature application viewsthat can be embedded in other applications (such as the Home screen) andreceive periodic updates. These views are referred to as Widgets in the userinterface, and you can publish one with an App Widget provider.An application component that is able to hold other App Widgets is called anApp Widget host. The screenshot below shows the Music App Widget.
App Widgets 即应用程序小部件,可以理解为嵌在其他的应用程序(比如常见的桌面上的)中的,可以按一定频率更新的小型的应用程序视图。比如,可以加载到桌面上的天气预报,clock,新浪微博。。App Widgets可以利用App Widget provider来发布。
To create an App Widget, you need the following:
AppWidgetProviderInfo object
Describesthe metadata for an App Widget, such as the App Widget's layout, updatefrequency, and the AppWidgetProvider class. This should be defined in XML.
AppWidgetProvider class implementation
Definesthe basic methods that allow you to programmatically interface with the AppWidget, based on broadcast events. Through it, you will receive broadcasts whenthe App Widget is updated, enabled, disabled and deleted.
View layout
Definesthe initial layout for the App Widget, defined in XML.
Additionally, you can implement an App Widget configurationActivity. This is an optional Activity that launches when the user adds your App Widget and allowshim or her to modify App Widget settings at create-time.
The following sections describe how to setup each of thesecomponents.