7

I encountered wierd behaviour on some devices when add new instance of appwidget on the home screen.

I've got AppWidget application with configuration activity. As it was said in tutorial update of appwidget I have to do by myself.

    public static void updateWidgetAndSendIntent (Activity activity, int mAppWidgetId, boolean isUpdate) {
    updateWidgets(activity);
    if (!isUpdate) {
        Intent resultIntent = new Intent();
        resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
        activity.setResult(Activity.RESULT_OK, resultIntent);
        activity.finish();
    }
}

    public static void updateWidgets(Context context) {
    new ManagerUpdateWidget(context).updateAllWidgetInstances();
}

ManagerUpdateWidget.java

    public void updateAllWidgetInstances() {

    Bitmap widget = getCustomView(context);

    for (int widgetId : appWidgetIds) {
        updateCurrentInstance(widgetId, widget);
    }
}

The fact is that on Samsung Galaxy Note 2 (GT-N7100) with Android 4.4.2 everything is Ok, but on Samsung Galaxy Note 3 (SM-N900) with Android 5.0 I've got "phantom" appwidget, not real appawidget on the home screen but the "phantom" ones when you cann't see appwidget on screen but inside your app appwidget exists with ID and regulary updates. I've tested my app on genymotion emulators (Android 4.3 and 5.0) but everything was Ok too.

Please, suggest me how to fix this wierd bug.

Alex Zezekalo
  • 1,031
  • 2
  • 17
  • 34
  • Can you clarify what do mean by "phantom" appwidget? – Bilal Haider Oct 08 '15 at 12:56
  • [This](http://stackoverflow.com/a/8866791/4600792) answer might help you. – Bilal Haider Oct 08 '15 at 13:03
  • this is another bug, not mine. I see my widget in "Widget list" and can run Configuration Activity but after config is finished I don't see new instance on home screen. In my case it only happends on Note 3, on Note 2 running is ok – Alex Zezekalo Oct 08 '15 at 14:21

1 Answers1

0

Dealing with "phantom" widgets it's a nightmare. Can you update all the instances using updateAppWidget (ComponentName provider, RemoteViews views)?
According to the documentation, this method is going to set the RemoteViews to use for all AppWidget instances for the supplied AppWidget provider.

AppWidgetManager manager = AppWidgetManager.getInstance(context);
ComponentName component = new ComponentName(context, MyAppWidgetProvider.class);
manager.updateAppWidget(component, remoteViews);
rlukas
  • 16
  • 2