4

In my app, I want to list ALL home screen widgets. My code is like this:

mWidgetInfoList = AppWidgetManager.getInstance(getActivity()).getInstalledProviders();
int count = 0;
for (AppWidgetProviderInfo one: mWidgetInfoList) {
  Log.d(TAG, "onViewCreated, widget " + count + ": " + one.label + ", " + one.toString());
  count++;
}

It work almost ok. The question is: getInstalledProviders() just returns a incomplete list. For example, in my Samsung Note3 (Android 5.0), two of the widgets not returned by getInstalledProviders() are "S Planner", which are two different size calendar widgets, as shown by Samsung TouchWiz.

But there is also another widget not shown by TouchWiz, which is "Calendar". Log shows it appears to be actually S Planner itself:

05-04 16:23:12.977  30699-30699/com.lxj.simplehome D/WidgetListFragment﹕ onViewCreated, widget 16: Calendar, AppWidgetProviderInfo(provider=ComponentInfo{com.sec.android.widgetapp.SPlannerAppWidget/com.sec.android.widgetapp.SPlannerAppWidget.EasyWidget.EasyCalendarAppWidgetProvider})

So, how to get full list (with different sizes)?

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
wizardlee
  • 53
  • 6

2 Answers2

0

The only way that I know, is using root access. It is not always guaranteed to work (especially if the user has a custom home screen).

There is a database at:

/data/data/com.android.launcher/databases/launcher.db

This database contains the rows for all widgets and icons on the homescreen. Here is an example of mine:

Example database contents

Knossos
  • 15,802
  • 10
  • 54
  • 91
  • On my phone, this file not exist, while another seems to be the one you mention: data/data/com.sec.android.app.launcher/databases/launcher.db. However, it just contains 3 tables: android_metadata, appOrder, favorite. None of them looks like widget list. Your screenshot looks like the "favorites" table on my phone. – wizardlee May 05 '15 at 01:44
0

Unlucky some built-in widgets may not be available for third party launcher due to limitations imposed by manufacturers.

evi
  • 864
  • 1
  • 9
  • 18
  • Actually what I'm looking for is a way to disable them, not a way to launch them. I can disable them with `setApplicationHidden`, but I need to get a list of them first. – andybalholm Oct 16 '17 at 18:35
  • I'm awarding you my bounty since your answer was the only new one in the bounty period. – andybalholm Oct 16 '17 at 18:42