I'm trying to read the available home screen widgets list on Android. I can populate a grid using the available applications list using
Intent myIntent = new Intent(Intent.ACTION_MAIN, null);
myIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> appsInfo = MyActivity.getPackageManager().queryIntentActivities(myIntent, 0);
and than iterating through each ResolveInfo.
How can I do the same with available Home screen widgets? I'd like to populate a grid with the same list that appears keep touching the screen and choosing 'widget' from the appearing popup.
First, touch hold an open space on your home screen. You'll see an option at the bottom of the screen to view the widgets drawer, which is where they dwell until summoned for duty. Select the widgets drawer, then browse through the choices.
The widgets are usually stored within the application apk. As far as the power controls, my guess would be framework-res. apk in /system/framework...
Long press on an empty area of your home screen where you want to add a widget. From the menu that shows up, tap Widgets. Tap and hold the widget that you'd like to add to your home screen. All the available widget sizes will also be shown to you in this very panel.
As suggested by CommonsWare, here is the working code for extracting list of widgets
AppWidgetManager manager = AppWidgetManager.getInstance(this);
List<AppWidgetProviderInfo> infoList = manager.getInstalledProviders();
for (AppWidgetProviderInfo info : infoList) {
Log.d(TAG, "Name: " + info.label);
Log.d(TAG, "Provider Name: " + info.provider);
Log.d(TAG, "Configure Name: " + info.configure);
}
Various other values can be extracted, for more reference see AppWidgetProviderInfo
Call getInstalledProviders()
on an AppWidgetManager
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With