Fix NPE caused by the selected entry is not valid when make a phone call
Change-Id: Ifc974f43be4e58ca69f150a29d4b7e9a0670f08f
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index 551a79c..000f129 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -715,16 +715,19 @@
int index = mListView.getSelectedItemPosition();
if (index != -1) {
ViewEntry entry = ViewAdapter.getEntry(mSections, index, SHOW_SEPARATORS);
- if (entry.intent.getAction() == Intent.ACTION_CALL_PRIVILEGED) {
+ if (entry != null &&
+ entry.intent.getAction() == Intent.ACTION_CALL_PRIVILEGED) {
startActivity(entry.intent);
+ return true;
}
} else if (mPrimaryPhoneUri != null) {
// There isn't anything selected, call the default number
final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
mPrimaryPhoneUri);
startActivity(intent);
+ return true;
}
- return true;
+ return false;
}
case KeyEvent.KEYCODE_DEL: {