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.