I have problem with PreferenceActivity
used to set preferences for app widget. The thing is, that when I want to pass to the PreferenceActivity
any info via Intent
only at the first time I am able to read them. After when information sended in Intent
are different, those earlier sended are still saved and I don't see new one. The only thing to do that is to remove completly app from system and install again. But then again everything will looks this same (first info will stay). The other important thing is that I am not saving it anywhere, just showing it in label text and in LogCat
.
Those are code fragments responsible for this:
Widget activity
// Actions required to open settings activity
Intent intentSettings = new Intent(context, PrefActivity.class);
intentSettings.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,
appWidgetIds);
intentSettings.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, (allWidgetIds.length+number));
PendingIntent pendingIntentSettings = PendingIntent.getActivity(
context, 0, intentSettings, 0);
remoteViews.setOnClickPendingIntent(R.id.imb_ustawienia,
pendingIntentSettings);
Preference activity
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("Info","onCreate");
addPreferencesFromResource(R.xml.pref);
Bundle intentIn = getIntent().getExtras();
Log.d("SIZE", "" + intentIn.size());
if (intentIn == null) {
Log.d("Tag","Intent is empty");
}
else
{
widgetId = intentIn.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
allWidgetIds = intentIn.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
Log.d("Pref","id: " + widgetId + " ids: " + allWidgetIds.length);
}
final CheckBoxPreference checkboxPref1 = (CheckBoxPreference) getPreferenceManager().findPreference("checkboxPref1");
//...
final Preference opt1 = (Preference) findPreference("settings1");
opt1.setSummary("Widget's id: " + widgetId);
opt1.setOnPreferenceClickListener(new OnPreferenceClickListener() {
//...
}
@Override
protected void onStop() {
super.onStop();
Intent infoIntent = new Intent(DataAppWidgetProvider.FORCE_WIDGET_UPDATE);
infoIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
this.sendBroadcast(infoIntent);
finish();
}
Do you know, what can be a problem? It looks like something is saved somewhere without my will and this is blocking everything.