Java tutorial
//package com.java2s; //License from project: Open Source License import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android.content.ComponentName; import android.content.Context; public class Main { public static int[] getAppWidgetIds(final Context context, final AppWidgetManager appWidgetManager, final Class<? extends AppWidgetProvider> widgetProviderClass) { ComponentName thisAppWidget = new ComponentName(context.getPackageName(), widgetProviderClass.getName()); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget); return appWidgetIds; } }