I have some problems with my widgets. Here is the description:
Context:
I have a home widget.
When I add it, it pops a configuration
I solved this problem like this,
in the widget provider's onUpdate() method I check if the widget was configured, and if it wasn't I don't do anything, so no ghost widgets. At the end of the configuration I just set it to true and I'm good to go. Just don't forget to remove it from sharedpreference when the widget is deleted.
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{
super.onUpdate(context, appWidgetManager, appWidgetIds);
for(final int appWidgetId : appWidgetIds)
{
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(appWidgetId);
stringBuilder.append("_conf");
if(context.getSharedPreferences("settings",0).getBoolean(stringBuilder.toString(),false))
updateAppWidget(context,appWidgetId,appWidgetManager);
}
}