Home | History | Annotate | Download | only in WeatherListWidget
      1 <p>This sample demonstrates how to create a list-based widget specifically backed by a content provider.<br/>
      2 <em>Please make sure that you understand the earlier stack widget sample code before delving into this example
      3  (see <a href="../StackWidget/index.html">StackWidget</a>).</em></p>
      4 
      5 <p>As in the StackWidget example, we will be using a collection view (the ListView in this case) to
      6 present some mock weather data in a widget.  In particular, we will be using a content provider to
      7 demonstrate how the widget can retrieve data and update itself when you are using more complex data
      8 sources.  When working with external data, or data which must be fetched over high latency, it is
      9 important to keep the data cached in a persistent location so that the widget feels responsive.</p>
     10 
     11 <p>This sample uses the following classes:
     12 	<ul>
     13 		<li><a href="src/com/example/android/weatherlistwidget/WeatherDataProvider.html"><code>WeatherDataProvider</code></a> &mdash;
     14 			Our ContentProvider which stores the weather data for this sample.  Note that for simplicity,
     15 			it currently stores the data in memory as opposed to an external and persistent storage such
     16 			as a file, network location, database, or shared preference.
     17 		</li>
     18 		<li><a href="src/com/example/android/weatherlistwidget/WeatherWidgetProvider.html"><code>WeatherWidgetProvider</code></a> &mdash;
     19 			Our AppWidgetProvider which handles specific intent actions (such as when an item is clicked,
     20 			or the refresh button is pressed).  It also sets up the RemoteViews for the widget and binds
     21 			the service to the collection view in the widget.
     22 		</li>
     23 		<li><a href="src/com/example/android/weatherlistwidget/WeatherWidgetService.html"><code>WeatherWidgetService</code></a> &mdash;
     24 			Our RemoteViewsService which manages the creation of new factories, which return the RemoteViews
     25 			for each item in the ListView.
     26 		</li>
     27 	</ul>
     28 </p>
     29 
     30 <p>If you are writing collection-based widgets, remember that the feature is
     31 supported only on Android 3.0 (API level 11) and higher versions of the platform.
     32 Remember to add the following to the application's manifest publishing to Google Play:</p>
     33 
     34 <ul>
     35 <li><code>&lt;uses-sdk android:minSdkVersion="11" /&gt;</code>, which indicates
     36 to Google Play and the platform that your application requires Android 3.0 or
     37 higher. For more information, see the <a href="../../../guide/appendix/api-levels.html">API Levels</a>
     38 and the documentation for the
     39 <a href="../../../guide/topics/manifest/uses-sdk-element.html"><code>&lt;uses-sdk&gt;</code></a>
     40 element.</li>
     41 </ul>
     42 
     43 <img alt="Screenshot" src="../images/WeatherListWidget.png" />