A Restaurant In Your Own Home
Figure 57. The very boring LunchList widget
Step #6: Show a Random Restaurant
Finally, we need to add some smarts that will actually display a random
restaurant in the app widget. To do this, we will override the onUpdate()
method in our AppWidget class and have it do the database I/O to find a
random restaurant.
With that in mind, add the following onUpdate() implementation to
AppWidget:
@Override
public void onUpdate(Context ctxt,
AppWidgetManager mgr,
int[] appWidgetIds) {
ComponentName me=new ComponentName(ctxt, AppWidget.class);
RemoteViews updateViews=new RemoteViews("apt.tutorial",
R.layout.widget);
RestaurantHelper helper=new RestaurantHelper(ctxt);
try {
Cursor c=helper