Always re-read RawContacts._ID before editing.
In cases where the user hasn't selected a tab, and there is
no "All" tab present (a single RawContact), this code would
try reading details for the second tab that didn't exist.
This fixes http://b/2072410
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index 2fd22b1..da49188 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -385,10 +385,11 @@
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_ITEM_EDIT: {
- long rawContactIdToEdit = mSelectedRawContactId;
+ final int tabIndex = mTabWidget.getCurrentTab();
+ long rawContactIdToEdit = getTabRawContactId(tabIndex);
if (rawContactIdToEdit == ALL_CONTACTS_ID) {
// If the "all" tab is selected, edit the next tab.
- rawContactIdToEdit = getTabRawContactId(mTabWidget.getCurrentTab() + 1);
+ rawContactIdToEdit = getTabRawContactId(tabIndex + 1);
}
Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI,
rawContactIdToEdit);