Android : text from EdittextPreference

on Wednesday, September 3, 2014


My EditTextPreference is this:



<EditTextPreference
android:title="Name"
android:summary="namepreferences"
android:inputType="text"
android:dialogTitle="name"
/>


in my PreferencesActivity:



namePref = (EditTextPreference)getPreferenceManager().findPreference("namepreferences");


well so far no problem.. now, i have a service with a notification. My goal is pass the namePref value in the Title of the notification.. I wrote this in the service:



SharedPreferences sp = PreferenceManager.getDefaultPreferences(this);
String name;

@Override
public void onCreate() {
name = sp.getText("namepreferences", "NA");

}


and i insert name in the title of notification but the app crashes sayng that name is null.. I can't solve..


0 comments:

Post a Comment