From 9258827315ff3a6fc28acad4854af4c8e7faa8de Mon Sep 17 00:00:00 2001 From: Andy Stadler Date: Fri, 25 Mar 2011 16:29:53 -0700 Subject: [PATCH] DO NOT MERGE - Prevent NPE when account sender name is null Bug: 3500373 Backport of: Id07270f34d9cc0523c46104b3167711b71798623 Change-Id: I23464e3edd9c8d8ecc54451cf7eabfddb73bd745 --- src/com/android/email/activity/setup/AccountSettings.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/android/email/activity/setup/AccountSettings.java b/src/com/android/email/activity/setup/AccountSettings.java index 49df69cd8..218788bca 100644 --- a/src/com/android/email/activity/setup/AccountSettings.java +++ b/src/com/android/email/activity/setup/AccountSettings.java @@ -150,8 +150,11 @@ public class AccountSettings extends PreferenceActivity { }); 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();