cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject [1/2] git commit: CB-7003: Make pickContact pick correct contact on Android 4.3 and 4.4.3
Date Wed, 02 Jul 2014 14:06:10 GMT
Repository: cordova-plugin-contacts
Updated Branches:
  refs/heads/0.2.11 edc744aa5 -> 104c56561


CB-7003: Make pickContact pick correct contact on Android 4.3 and 4.4.3


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/aef7032e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/aef7032e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/aef7032e

Branch: refs/heads/0.2.11
Commit: aef7032ea4670b381b3bca70cec091f93667f8d5
Parents: edc744a
Author: sgrebnov <v-segreb@microsoft.com>
Authored: Mon Jun 30 15:46:26 2014 +0400
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Wed Jul 2 09:52:41 2014 -0400

----------------------------------------------------------------------
 src/android/ContactManager.java | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/aef7032e/src/android/ContactManager.java
----------------------------------------------------------------------
diff --git a/src/android/ContactManager.java b/src/android/ContactManager.java
index e1a4568..1bb9c43 100644
--- a/src/android/ContactManager.java
+++ b/src/android/ContactManager.java
@@ -27,7 +27,9 @@ import org.json.JSONObject;
 
 import android.app.Activity;
 import android.content.Intent;
+import android.database.Cursor;
 import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.RawContacts;
 import android.util.Log;
 
 public class ContactManager extends CordovaPlugin {
@@ -161,8 +163,19 @@ public class ContactManager extends CordovaPlugin {
         if (requestCode == CONTACT_PICKER_RESULT) {
             if (resultCode == Activity.RESULT_OK) {
                 String contactId = intent.getData().getLastPathSegment();
+                // to populate contact data we require  Raw Contact ID
+                // so we do look up for contact raw id first
+                Cursor c =  this.cordova.getActivity().getContentResolver().query(RawContacts.CONTENT_URI,
+                            new String[] {RawContacts._ID}, RawContacts.CONTACT_ID + " =
" + contactId, null, null);
+                if (!c.moveToFirst()) {
+                    this.callbackContext.error("Error occured while retrieving contact raw
id");
+                    return;
+                }
+                String id = c.getString(c.getColumnIndex(RawContacts._ID));
+                c.close();
+
                 try {
-                    JSONObject contact = contactAccessor.getContactById(contactId);
+                    JSONObject contact = contactAccessor.getContactById(id);
                     this.callbackContext.success(contact);
                     return;
                 } catch (JSONException e) {


Mime
View raw message