Ashraf Alshahawy
Ashraf Alshahawy

Reputation: 1189

AppWidgetManager.getInstalledProviders() doesn't return all installed widgets

I use the following code to return all available (installed) widgets. But it doesn't return all of them. In my case, it returns 47 widgets, while the stock launcher has 73 widgets.

AppWidgetManager mAppWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
List<AppWidgetProviderInfo> infoList = mAppWidgetManager.getInstalledProviders();

for (AppWidgetProviderInfo info : infoList) {

}

Upvotes: 1

Views: 341

Answers (1)

Ashraf Alshahawy
Ashraf Alshahawy

Reputation: 1189

Thanks to @CommonsWare's assistance, these extras are not widgets, they are shortcuts to activities that are fetched using the following code.

Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
List<ResolveInfo> shortcuts = getPackageManager().queryIntentActivities(shortcutsIntent, 0);

Upvotes: 2

Related Questions