Code example for AppWidgetHost

Methods: allocateAppWidgetId

0
	int allocateWidgetId() { 
		try { 
            Context packageContext = context.createPackageContext(
                    DashconfigApplication.getDeviceContext() 
                            .getStringConst(context, "TWLAUNCHER_COMP"), 0);
			AppWidgetHost host = new AppWidgetHost(packageContext, 1024);
 
			return host.allocateAppWidgetId();
		} catch (NameNotFoundException e) {
			DashLogger.e(TAG, "NameNotFoundException: " + e.getMessage());
		} catch (Exception e) {
			DashLogger.e(TAG, "Exception in allocateWidgetId : " + e.getMessage());
		} 
		return -1; 
	} 
 
	protected void createWidgetsAndShortcuts() { 
 
		for (int index = 0; index < widgetsAndShortcutsList.size(); index++) {
			JSONObject item = widgetsAndShortcutsList.get(index);
Connect your IDE to all the code out there  Get Codota for Java