From 2d6a98aedf10a8f836ae2e02ddbdec597cf53899 Mon Sep 17 00:00:00 2001 From: Andy Stadler Date: Tue, 1 Mar 2011 22:19:53 -0800 Subject: [PATCH] Prevent NPE when account sender name is null Bug: 3500373 Change-Id: Id07270f34d9cc0523c46104b3167711b71798623 --- .../email/activity/setup/AccountSettingsFragment.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/android/email/activity/setup/AccountSettingsFragment.java b/src/com/android/email/activity/setup/AccountSettingsFragment.java index adbf88970..f82da2890 100644 --- a/src/com/android/email/activity/setup/AccountSettingsFragment.java +++ b/src/com/android/email/activity/setup/AccountSettingsFragment.java @@ -381,8 +381,11 @@ public class AccountSettingsFragment extends PreferenceFragment { ); mAccountName = (EditTextPreference) findPreference(PREFERENCE_NAME); - mAccountName.setSummary(mAccount.getSenderName()); - mAccountName.setText(mAccount.getSenderName()); + String senderName = 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() { public boolean onPreferenceChange(Preference preference, Object newValue) { final String summary = newValue.toString().trim();