Very bad design on AppWidgets in android.
To reproduce the bug:
- Select Widget ( to drop on home screen )
- Select Back ( hardware key ) to cancel drop widget
- Now you have hidden widget.
I was included setResult(RESULT_CANCELED);
to prevent this issue, but will not handle by android framework!!!
So I used this code as an stupid solution:
@Override
protected void onDestroy() {
if ( !submitted) {
AppWidgetHost host = new AppWidgetHost(this, 1);
host.deleteAppWidgetId(mAppWidgetId);
}
}