Error: appWidgetId (EXTRA_APPWIDGET_ID) was not returned from the \widget configuration activity.
按HOME按鈕不會從配置活動
public class WidgetConfigure extends Activity {
private int widgetID;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v("Lifecycle", "WidgetConfigure.onCreate");
setContentView(R.layout.widget_configure);
widgetID = this.getIntent().getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
setResult(RESULT_CANCELED, new Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetID));
}
public void onButtonClicked(View view) {
Log.v("Lifecycle", "WidgetConfigure.onButtonClicked");
if (((RadioButton) this.findViewById(RefreshStrategy.SYSTEM)).isChecked()) {
WidgetProvider.configure(widgetID, true);
} else if (((RadioButton) this.findViewById(RefreshStrategy.USER)).isChecked()) {
WidgetProvider.configure(widgetID, false);
}
setResult(RESULT_OK, new Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetID));
finish();
}
}
理論上RESULT_OK
應該在任何其他情況下按下活動按鈕和RESULT_CANCELED
後發送回控件ID,但它不會發生HOME就當物理按鈕設備被按下。
任何想法如何解決這個問題?
作爲一個用戶,它不能很好地發揮出來。許多用戶在小部件配置後按下主頁按鈕,並想知道爲什麼不添加小部件!我收到了這樣的查詢的百分之一。 – 3c71
@ 3c71我個人同意,但我是誰來反對hackbod的智慧。 –