I have a number of Colors that can be set by the user in preferences. For that I have an Activity with a ColorPicker. The problem is don't know how to pass the key of the color being changed to the ColorPicker so it can save it in SharedPreferences.
<Preference
android:title="@string/pref_text_color"
>
<intent android:targetPackage="com.example.android.launcher"
android:targetClass="com.example.android.launcher.preferences.ColorPicker" />
<!-- Pass value "textColor" -->
</Preference>
How can this be done?
You can add data with the Intent to your ColorPicker activity in the following manner:
Intent intent = new Intent(this, ColorPickerActivity.class);
intent.putExtra("UNIQUE_KEY_FOR_THIS_COLOR_INFORMATION", colorIndex);
and retrieve it at your receiving side:
getIntent().getIntExtra("UNIQUE_KEY_FOR_THIS_COLOR_INFORMATION", -1);
where -1 is the default data if no value for that key is found.
Android has a pretty detailed documentation of Intents, which you should go through: http://developer.android.com/reference/android/content/Intent.html