Permalink
Browse files

This change allows the return of Email address information form the c…

…ontacts list.
  • Loading branch information...
MikeMyhre committed Sep 13, 2011
1 parent c9fbe85 commit 00a0883de95fd7539cd386f0c28906971f87d365
Showing with 16 additions and 0 deletions.
  1. +16 −0 Android/ContactView/ContactView.java
@@ -36,6 +36,7 @@ public void startContactActivity() {
public void onActivityResult(int reqCode, int resultCode, Intent data) {
String name = null;
String number = null;
+ String email = null;
switch (reqCode) {
case (PICK_CONTACT):
if (resultCode == Activity.RESULT_OK) {
@@ -59,12 +60,27 @@ public void onActivityResult(int reqCode, int resultCode, Intent data) {
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
}
+ // get email address
+ Cursor emailCur = this.ctx.managedQuery(
+ ContactsContract.CommonDataKinds.Email.CONTENT_URI,
+ null,
+ ContactsContract.CommonDataKinds.Email.CONTACT_ID + "='" + ContactID + "'", null,null);
+ while (emailCur.moveToNext()) {
+ // This would allow you get several email addresses
+ // if the email addresses were stored in an array
+ email = emailCur.getString(
+ emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
+ //String emailType = emailCur.getString(
+ // emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
+ }
+ emailCur.close();
name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
JSONObject contactObject = new JSONObject();
try {
contactObject.put("name", name);
contactObject.put("phone", number);
+ contactObject.put("email", email);
} catch (JSONException e) {
e.printStackTrace();
}

1 comment on commit 00a0883

awesome!

Please sign in to comment.