/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.apis.appwidget; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.os.SystemClock; import android.util.Log; import android.widget.RemoteViews; // Need the following import to get access to the app resources, since this // class is in a sub-package. import com.example.android.apis.R; /** * A widget provider. We have a string that we pull from a preference in order to show * the configuration settings and the current time when the widget was updated. We also * register a BroadcastReceiver for time-changed and timezone-changed broadcasts, and * update then too. * *

See also the following files: *

*/ public class ExampleAppWidgetProvider extends AppWidgetProvider { // log tag private static final String TAG = "ExampleAppWidgetProvider"; @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Log.d(TAG, "onUpdate"); // For each widget that needs an update, get the text that we should display: // - Create a RemoteViews object for it // - Set the text in the RemoteViews object // - Tell the AppWidgetManager to show that views object for the widget. final int N = appWidgetIds.length; for (int i=0; i