FileDocCategorySizeDatePackage
TestAppWidgetProvider.javaAPI DocAndroid 1.5 API2320Wed May 06 22:42:02 BST 2009com.android.tests.appwidgetprovider

TestAppWidgetProvider

public class TestAppWidgetProvider extends android.content.BroadcastReceiver

Fields Summary
static final String
TAG
Constructors Summary
Methods Summary
public voidonReceive(android.content.Context context, android.content.Intent intent)


          
        String action = intent.getAction();
        Log.d(TAG, "intent=" + intent);

        if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) {
            Log.d(TAG, "ENABLED");
        }
        else if (AppWidgetManager.ACTION_APPWIDGET_DISABLED.equals(action)) {
            Log.d(TAG, "DISABLED");
        }
        else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
            Log.d(TAG, "UPDATE");
            Bundle extras = intent.getExtras();
            int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);

            AppWidgetManager gm = AppWidgetManager.getInstance(context);
            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.test_appwidget);
            views.setTextViewText(R.id.oh_hai_text, "hai: " + SystemClock.elapsedRealtime());
            if (false) {
                gm.updateAppWidget(appWidgetIds, views);
            } else {
                gm.updateAppWidget(new ComponentName("com.android.tests.appwidgetprovider",
                            "com.android.tests.appwidgetprovider.TestAppWidgetProvider"), views);
            }
        }