Supporting EXTRA_APPWIDGET_OPTIONS correctly

This commit is contained in:
Michael Jurka
2012-11-05 18:56:14 -08:00
parent fd34f98960
commit ab3472f594

View File

@@ -84,6 +84,7 @@ public class KeyguardAppWidgetPickActivity extends Activity
private Intent mResultData; private Intent mResultData;
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
private boolean mSuccess; private boolean mSuccess;
private Bundle mExtraConfigureOptions;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@@ -101,6 +102,7 @@ public class KeyguardAppWidgetPickActivity extends Activity
} else { } else {
finish(); finish();
} }
mExtraConfigureOptions = intent.getBundleExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS);
mGridView = (GridView) findViewById(R.id.widget_list); mGridView = (GridView) findViewById(R.id.widget_list);
mAppWidgetManager = AppWidgetManager.getInstance(this); mAppWidgetManager = AppWidgetManager.getInstance(this);
@@ -466,12 +468,8 @@ public class KeyguardAppWidgetPickActivity extends Activity
setResultData(result, intent); setResultData(result, intent);
} else { } else {
try { try {
Bundle options = null; mAppWidgetManager.bindAppWidgetId(
if (intent.getExtras() != null) { mAppWidgetId, intent.getComponent(), mExtraConfigureOptions);
options = intent.getExtras().getBundle(
AppWidgetManager.EXTRA_APPWIDGET_OPTIONS);
}
mAppWidgetManager.bindAppWidgetId(mAppWidgetId, intent.getComponent(), options);
result = RESULT_OK; result = RESULT_OK;
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// This is thrown if they're already bound, or otherwise somehow // This is thrown if they're already bound, or otherwise somehow