diff --git a/src/com/fsck/k9/helper/ContactsSdk3_4.java b/src/com/fsck/k9/helper/ContactsSdk3_4.java index 068a55443..0b2433417 100644 --- a/src/com/fsck/k9/helper/ContactsSdk3_4.java +++ b/src/com/fsck/k9/helper/ContactsSdk3_4.java @@ -225,30 +225,30 @@ public class ContactsSdk3_4 extends com.fsck.k9.helper.Contacts { @Override public Intent contactPickerIntent() { return new Intent(Intent.ACTION_PICK, Contacts.People.CONTENT_URI); - } - @Override public String getEmailFromContactPicker(final Intent data) { - Cursor cursor = null; Cursor cursor2 = null; String email = ""; try { - Uri result = data.getData(); - cursor = mContentResolver.query(result, null, null, null, null); + cursor = mContentResolver.query(result, null, null, null, null); if (cursor.moveToFirst()) { String emailId = cursor.getString(cursor.getColumnIndex(Contacts.People.PRIMARY_EMAIL_ID)); - cursor2 = mContext.getContentResolver().query(ContactMethods.CONTENT_EMAIL_URI, new String[] { ContactMethods.DATA }, "contact_methods._id=?", new String[] { emailId }, null); + cursor2 = mContext.getContentResolver().query( + ContactMethods.CONTENT_EMAIL_URI, + new String[] { ContactMethods.DATA }, + "contact_methods._id=?", + new String[] { emailId }, + null); + if (cursor2.moveToFirst()) { email = cursor2.getString(0); } - } - } catch (Exception e) { Log.e(K9.LOG_TAG, "Failed to get email data", e); } finally { @@ -263,8 +263,6 @@ public class ContactsSdk3_4 extends com.fsck.k9.helper.Contacts { return email; } - - /** * Return a {@link Cursor} instance that can be used to fetch information * about the contact with the given email address. diff --git a/src/com/fsck/k9/helper/ContactsSdk5.java b/src/com/fsck/k9/helper/ContactsSdk5.java index a5d1327e7..40ae2768b 100644 --- a/src/com/fsck/k9/helper/ContactsSdk5.java +++ b/src/com/fsck/k9/helper/ContactsSdk5.java @@ -192,22 +192,20 @@ public class ContactsSdk5 extends com.fsck.k9.helper.Contacts { } } - @Override public Intent contactPickerIntent() { - return new Intent(Intent.ACTION_PICK, android.provider.ContactsContract.Contacts.CONTENT_URI); + return new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); } @Override public String getEmailFromContactPicker(final Intent data) { - Cursor cursor = null; String email = ""; + try { Uri result = data.getData(); - Log.v(K9.LOG_TAG, "Got a contact result: " + result.toString()); - // get the contact id from the Uri + // Get the contact id from the Uri String id = result.getLastPathSegment(); cursor = mContentResolver.query(Email.CONTENT_URI, null, Email.CONTACT_ID + "=?", new String[] { id },