samedi 12 septembre 2015

AppWidgetProvider not working in ContentProvider's fashion

Using the code shared by Xaver Kapeller in Trying to access the LauncherProvider I run into problems when Widgets are present in database:

After opening the cursor and traversing the loop like

while (!mStopped && c.moveToNext()) {
try {
int itemType = c.getInt(itemTypeIndex);
.....

and branching at:

case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
   //Read widget details
int appWidgetId = c.getInt(appWidgetIdIndex);
id = c.getLong(idIndex);
final AppWidgetProviderInfo provider = widgets.getAppWidgetInfo(appWidgetId);
if (!isSafeMode && (provider == null || provider.provider == null ||
provider.provider.getPackageName() == null)) {
if (!isSafeMode && (provider == null || provider.provider == null ||
provider.provider.getPackageName() == null)) {
Log.e(TAG, "Deleting widget that isn't installed anymore: id="
+ id + " appWidgetId=" + appWidgetId);

Here provider value returns as Null, yet there are two actual widgets in the database. What is broken here?

the Java codebase I use is at http://ift.tt/1V5Xzrc

Aucun commentaire:

Enregistrer un commentaire