Tuesday, 20 January 2015

What are Home Screen Widgets ?

* Home screen widgets are views that can be displayed on a home page and updated frequently.

* As a view, a widget's look and feel is defined through a layout XML file.

* For a widget, in addition  to the layout of the view, you will need to define how much space the view
of the widget will need on the home screen.

* A widget definition also includes a couple of java classes that are responsible for initializing the view and updating it frequently.

* These java classes are responsible for managing the life cycle of the widget on the home screen.

* These classes respond when the widget is dragged onto the home page, when the widget needs
to be updated, and when the widget is uninstalled by dragging it to the trash can.

A widget definition contains the following :

1- A view layout to be displayed on the home screen, along with how big it should be(at a minimum)
to fit on a home page.Keep in mind that this is just the view without any data.It will be the responsibility of a Java class to update the view.

2- A timer that specifies the frequency of updates.

3- A broadcast receiver Java class called a widget provider that can respond to timer updates in order to alter the view in some fashion by populating with the data.

* Once a widget is defined and the Java classes are provided, the widget will be available for the user to drag onto a home page.

No comments:

Post a Comment