Code example for AppWidgetManager

Methods: getAppWidgetIds

0
	 * @param appWidgetManager 
	 *            AppWidgetManager instance 
	 */ 
	private static void updateControlWidgets(final Context context, final AppWidgetManager appWidgetManager)
	{ 
		final boolean controlWidgetsExist = appWidgetManager.getAppWidgetIds(new ComponentName(context,
				ControlAppWidgetProvider.class)).length > 0;
		if (controlWidgetsExist)
			context.startService(new Intent(context, ControlAppWidgetService.class));
	} 
 
	/** 
	 * Updates all instances of the Toggle App Widgets 
	 *  
	 * @param context 
	 *            Context used to trigger updates 
	 * @param appWidgetManager 
	 *            AppWidgetManager instance 
	 */ 
	private static void updateToggleWidgets(final Context context, final AppWidgetManager appWidgetManager)
	{ 
		final boolean toggleWidgetsExist = appWidgetManager.getAppWidgetIds(new ComponentName(context,
				ToggleAppWidgetProvider.class)).length > 0;
		if (toggleWidgetsExist)
			context.startService(new Intent(context, ToggleAppWidgetService.class));
	}