Example usage for android.appwidget AppWidgetManager EXTRA_APPWIDGET_IDS

List of usage examples for android.appwidget AppWidgetManager EXTRA_APPWIDGET_IDS

Introduction

In this page you can find the example usage for android.appwidget AppWidgetManager EXTRA_APPWIDGET_IDS.

Prototype

String EXTRA_APPWIDGET_IDS

To view the source code for android.appwidget AppWidgetManager EXTRA_APPWIDGET_IDS.

Click Source Link

Document

An intent extra that contains multiple appWidgetIds.

Usage

From source file:com.homeworkreminder.Main.java

public static void updateAppWidget() {
    Intent intent = new Intent(context, Widget.class);
    intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    // Use an array and EXTRA_APPWIDGET_IDS instead of
    // AppWidgetManager.EXTRA_APPWIDGET_ID,
    // since it seems the onUpdate() is only fired on that:
    int ids[] = AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, Widget.class));
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
    context.sendBroadcast(intent);//from   w ww .ja v a2 s. c o  m
}