Merge "DO NOT MERGE - Prevent NPE when account sender name is null" into gingerbread

This commit is contained in:
Andy Stadler 2011-03-25 16:44:05 -07:00 committed by Android (Google) Code Review
commit 07a85746af

View File

@ -150,8 +150,11 @@ public class AccountSettings extends PreferenceActivity {
}); });
mAccountName = (EditTextPreference) findPreference(PREFERENCE_NAME); mAccountName = (EditTextPreference) findPreference(PREFERENCE_NAME);
mAccountName.setSummary(mAccount.getSenderName()); String senderName = mAccount.getSenderName();
mAccountName.setText(mAccount.getSenderName()); // In rare cases, sendername will be null; Change this to empty string to avoid NPE's
if (senderName == null) senderName = "";
mAccountName.setSummary(senderName);
mAccountName.setText(senderName);
mAccountName.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { mAccountName.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final String summary = newValue.toString(); final String summary = newValue.toString();