Fix NPE due to uncomputed formatted phone numbers
Compute the formatted phone number in the case that it
was not computed from the ContactLoader. This can happen
because contacts loaded via the QuickContacts activity are
passed into the ContactDetailFragment, but the formatted
phone numbers are not computed in QuickContacts.
Bug: 7003015
Change-Id: I999b6ba8e3e3292b055a8fa1fe667a5c8304c983
diff --git a/src/com/android/contacts/detail/ContactDetailFragment.java b/src/com/android/contacts/detail/ContactDetailFragment.java
index 87c321e..cde1215 100644
--- a/src/com/android/contacts/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailFragment.java
@@ -573,6 +573,15 @@
PhoneDataItem phone = (PhoneDataItem) dataItem;
// Build phone entries
entry.data = phone.getFormattedPhoneNumber();
+ if (entry.data == null) {
+ // This case happens when the quick contact was opened from the contact
+ // list, and then, the user touches the quick contact image and brings the
+ // user to the detail card. In this case, the Contact object that was
+ // loaded from quick contacts does not contain the formatted phone number,
+ // so it must be loaded here.
+ phone.computeFormattedPhoneNumber(mDefaultCountryIso);
+ entry.data = phone.getFormattedPhoneNumber();
+ }
final Intent phoneIntent = mHasPhone ?
ContactsUtils.getCallIntent(entry.data) : null;
final Intent smsIntent = mHasSms ? new Intent(Intent.ACTION_SENDTO,