private void submit()
{
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String listprefs = SP.getString("listprefs","1");
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String[] recipients = new String[]{""};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, );
I am not sure if this is even possible, but I am needing to have the value that is selected in the list preference to show in the subject of an email. This is part of the code for the submit function of the app.
It works fine the way it is, but I am needing what the user selects to show in the emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT line so it will auto populate when the email is generated.
I have tried just about everything I can find on here and through other searches and have not had any luck.
If you want the displayed value:
If you want the internal value, just this will do:
Alternatively, you could retrieve the value using the PreferenceManager object, like you’re doing already. But if you’re already in the same activity, it’s easier to call the ListPreference I believe.
Of course, I assume you initialized your listpreference object properly. Could be: