Code example for AppWidgetHost

Methods: allocateAppWidgetId

0
			boolean allocatedAppWidgets = false;
			final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
 
			try 
			{ 
				int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
 
//				values.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET); 
//				values.put(Favorites.SPANX, spanX); 
//				values.put(Favorites.SPANY, spanY); 
//				values.put(Favorites.APPWIDGET_ID, appWidgetId); 
//				db.insert(TABLE_FAVORITES, null, values); 
				 
 
				allocatedAppWidgets = true;
 
				appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn);
			} 
			catch (RuntimeException ex)
			{ 
				Log.e(TAG, "Problem allocating appWidgetId", ex);