android.provider.ContactsContract Java Examples
The following examples show how to use
android.provider.ContactsContract.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginActivityA.java From ans-android-sdk with GNU General Public License v3.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { return new CursorLoader(this, // Retrieve data rows for the device user's 'profile' contact. Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI, ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION, // Select only email addresses. ContactsContract.Contacts.Data.MIMETYPE + " = ?", new String[]{ContactsContract.CommonDataKinds.Email .CONTENT_ITEM_TYPE}, // Show primary email addresses first. Note that there won't be // a primary email address if the user hasn't specified one. ContactsContract.Contacts.Data.IS_PRIMARY + " DESC"); }
Example #2
Source File: EspContactTool.java From espresso-macchiato with MIT License | 6 votes |
public static Uri addressUriByDisplayName(String contactName) { Uri result = null; Cursor cursor = InstrumentationRegistry.getTargetContext().getContentResolver().query( ContactsContract.Data.CONTENT_URI, null, ContactsContract.Data.MIMETYPE + " = ? ", new String[]{ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE}, null); assertNotNull(cursor); if (cursor.getCount() > 0) { while (cursor.moveToNext()) { String id = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal._ID)); String name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.DISPLAY_NAME)); if (contactName.equals(name)) { result = Uri.withAppendedPath(ContactsContract.Data.CONTENT_URI, id); break; } } } cursor.close(); return result; }
Example #3
Source File: ContactsActivity.java From PermissMe with Apache License 2.0 | 6 votes |
private ArrayList<String> getListOfContacts() { ArrayList<String> contactsList = new ArrayList<>(); ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if (cur != null && cur.getCount() > 0) { while (cur.moveToNext()) { String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); contactsList.add(name); } } if (contactsList.isEmpty()) { contactsList.add("No Contacts Found"); } return contactsList; }
Example #4
Source File: MainActivity.java From AndroidDemo with MIT License | 6 votes |
private void readContacts() { Cursor cursor = null; try { // 查询联系人数据 cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); if (cursor != null) { while (cursor.moveToNext()) { // 获取联系人姓名 String displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); // 获取联系人手机号 String number = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); contactsList.add(displayName + "\n" + number); } adapter.notifyDataSetChanged(); } } catch (Exception e) { e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } }
Example #5
Source File: ContactsTask.java From SmsScheduler with GNU General Public License v2.0 | 6 votes |
private HashMap<String, String> getNames() { HashMap<String, String> names = new HashMap<>(); // Getting contact names String[] projectionPeople = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; Cursor people = activity.getContentResolver().query( ContactsContract.Contacts.CONTENT_URI, projectionPeople, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC" ); if (null != people) { int columnIndexId = people.getColumnIndex(ContactsContract.Contacts._ID); int columnIndexName = people.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); while (people.moveToNext()) { names.put(people.getString(columnIndexId), people.getString(columnIndexName)); } people.close(); } return names; }
Example #6
Source File: ContactAccessorSdk5.java From cordova-android-chromeview with Apache License 2.0 | 6 votes |
/** * A special search that finds one contact by id * * @param id contact to find by id * @return a JSONObject representing the contact * @throws JSONException */ public JSONObject getContactById(String id) throws JSONException { // Do the id query Cursor c = mApp.getActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, ContactsContract.Data.CONTACT_ID + " = ? ", new String[] { id }, ContactsContract.Data.CONTACT_ID + " ASC"); JSONArray fields = new JSONArray(); fields.put("*"); HashMap<String, Boolean> populate = buildPopulationSet(fields); JSONArray contacts = populateContactArray(1, populate, c); if (contacts.length() == 1) { return contacts.getJSONObject(0); } else { return null; } }
Example #7
Source File: ContactsDatabase.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public synchronized void removeDeletedRawContacts(@NonNull Account account) { Uri currentContactsUri = RawContacts.CONTENT_URI.buildUpon() .appendQueryParameter(RawContacts.ACCOUNT_NAME, account.name) .appendQueryParameter(RawContacts.ACCOUNT_TYPE, account.type) .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true") .build(); String[] projection = new String[] {BaseColumns._ID, RawContacts.SYNC1}; try (Cursor cursor = context.getContentResolver().query(currentContactsUri, projection, RawContacts.DELETED + " = ?", new String[] {"1"}, null)) { while (cursor != null && cursor.moveToNext()) { long rawContactId = cursor.getLong(0); Log.i(TAG, "Deleting raw contact: " + cursor.getString(1) + ", " + rawContactId); context.getContentResolver().delete(currentContactsUri, RawContacts._ID + " = ?", new String[] {String.valueOf(rawContactId)}); } } }
Example #8
Source File: VCardContactEncoder.java From weex with Apache License 2.0 | 6 votes |
private static String vCardPurposeLabelForAndroidType(int androidType) { switch (androidType) { case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME: case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK: case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER_FAX: return "fax"; case ContactsContract.CommonDataKinds.Phone.TYPE_PAGER: case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER: return "pager"; case ContactsContract.CommonDataKinds.Phone.TYPE_TTY_TDD: return "textphone"; case ContactsContract.CommonDataKinds.Phone.TYPE_MMS: return "text"; default: return null; } }
Example #9
Source File: VCardContactEncoder.java From ZXing-Standalone-library with Apache License 2.0 | 6 votes |
private static String vCardPurposeLabelForAndroidType(int androidType) { switch (androidType) { case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME: case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK: case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER_FAX: return "fax"; case ContactsContract.CommonDataKinds.Phone.TYPE_PAGER: case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER: return "pager"; case ContactsContract.CommonDataKinds.Phone.TYPE_TTY_TDD: return "textphone"; case ContactsContract.CommonDataKinds.Phone.TYPE_MMS: return "text"; default: return null; } }
Example #10
Source File: ContactAccessorSdk5.java From jpHolo with MIT License | 6 votes |
/** * getPhoneType converts an Android phone type into a string * @param type * @return phone type as string. */ private String getOrgType(int type) { String stringType; switch (type) { case ContactsContract.CommonDataKinds.Organization.TYPE_CUSTOM: stringType = "custom"; break; case ContactsContract.CommonDataKinds.Organization.TYPE_WORK: stringType = "work"; break; case ContactsContract.CommonDataKinds.Organization.TYPE_OTHER: default: stringType = "other"; break; } return stringType; }
Example #11
Source File: VCardContactEncoder.java From ZXing-Orient with Apache License 2.0 | 6 votes |
private static String vCardContextLabelForAndroidType(int androidType) { switch (androidType) { case ContactsContract.CommonDataKinds.Phone.TYPE_HOME: case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE: case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME: case ContactsContract.CommonDataKinds.Phone.TYPE_PAGER: return "home"; case ContactsContract.CommonDataKinds.Phone.TYPE_COMPANY_MAIN: case ContactsContract.CommonDataKinds.Phone.TYPE_WORK: case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_MOBILE: case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK: case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER: return "work"; default: return null; } }
Example #12
Source File: MainActivity.java From Finder with GNU General Public License v3.0 | 6 votes |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_CONTACTS) { if (resultCode == RESULT_OK) { Uri uri = data.getData(); String[] columns_to_get = new String[] {ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME}; Cursor curs = getContentResolver().query(uri, columns_to_get, null, null, null); if (curs != null && curs.moveToFirst()) { String name = curs.getString(1); String number = curs.getString(0); field_name.setText(name); field_phone.setText(number.replaceAll("\\s+|-+|[()]+", "")); } } } }
Example #13
Source File: SharedContactRepository.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@WorkerThread private @Nullable Name getName(long contactId) { try (Cursor cursor = contactsDatabase.getNameDetails(contactId)) { if (cursor != null && cursor.moveToFirst()) { String cursorDisplayName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME)); String cursorGivenName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME)); String cursorFamilyName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME)); String cursorPrefix = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.PREFIX)); String cursorSuffix = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.SUFFIX)); String cursorMiddleName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME)); Name name = new Name(cursorDisplayName, cursorGivenName, cursorFamilyName, cursorPrefix, cursorSuffix, cursorMiddleName); if (!name.isEmpty()) { return name; } } } String org = contactsDatabase.getOrganizationName(contactId); if (!TextUtils.isEmpty(org)) { return new Name(org, org, null, null, null, null); } return null; }
Example #14
Source File: ContactAccessorSdk5.java From showCaseCordova with Apache License 2.0 | 6 votes |
/** * Converts a string from the W3C Contact API to it's Android int value. * @param string * @return Android int value */ private int getAddressType(String string) { int type = ContactsContract.CommonDataKinds.StructuredPostal.TYPE_OTHER; if (string != null) { if ("work".equals(string.toLowerCase())) { return ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK; } else if ("other".equals(string.toLowerCase())) { return ContactsContract.CommonDataKinds.StructuredPostal.TYPE_OTHER; } else if ("home".equals(string.toLowerCase())) { return ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME; } } return type; }
Example #15
Source File: ContactAccessorSdk5.java From showCaseCordova with Apache License 2.0 | 6 votes |
/** * getPhoneType converts an Android phone type into a string * @param type * @return phone type as string. */ private String getAddressType(int type) { String stringType; switch (type) { case ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME: stringType = "home"; break; case ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK: stringType = "work"; break; case ContactsContract.CommonDataKinds.StructuredPostal.TYPE_OTHER: default: stringType = "other"; break; } return stringType; }
Example #16
Source File: ContactPickerActivity.java From Android-ContactPicker with Apache License 2.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String selection = ""; if(mOnlyWithPhoneNumbers){ selection = ContactsContract.Contacts.HAS_PHONE_NUMBER; } switch(id) { case CONTACTS_LOADER_ID: return new CursorLoader(this, CONTACTS_URI, CONTACTS_PROJECTION, selection, null, CONTACTS_SORT); case CONTACT_DETAILS_LOADER_ID: return new CursorLoader(this, CONTACT_DETAILS_URI, CONTACT_DETAILS_PROJECTION, selection, null, null); case GROUPS_LOADER_ID: return new CursorLoader(this, GROUPS_URI, GROUPS_PROJECTION, GROUPS_SELECTION, null, GROUPS_SORT); } return null; }
Example #17
Source File: ContactsView.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView contactView = (TextView) findViewById(R.id.contactview); Cursor cursor = getContacts(); while (cursor.moveToNext()) { String displayName = cursor.getString(cursor .getColumnIndex(ContactsContract.Data.DISPLAY_NAME)); contactView.append("Name: "); contactView.append(displayName); contactView.append("\n"); } // Closing the cursor cursor.close(); }
Example #18
Source File: ContactAccessorSdk5.java From showCaseCordova with Apache License 2.0 | 6 votes |
/** * Converts a string from the W3C Contact API to it's Android int value. * @param string * @return Android int value */ private int getContactType(String string) { int type = ContactsContract.CommonDataKinds.Email.TYPE_OTHER; if (string != null) { if ("home".equals(string.toLowerCase())) { return ContactsContract.CommonDataKinds.Email.TYPE_HOME; } else if ("work".equals(string.toLowerCase())) { return ContactsContract.CommonDataKinds.Email.TYPE_WORK; } else if ("other".equals(string.toLowerCase())) { return ContactsContract.CommonDataKinds.Email.TYPE_OTHER; } else if ("mobile".equals(string.toLowerCase())) { return ContactsContract.CommonDataKinds.Email.TYPE_MOBILE; } else if ("custom".equals(string.toLowerCase())) { return ContactsContract.CommonDataKinds.Email.TYPE_CUSTOM; } } return type; }
Example #19
Source File: BaseImageDownloader.java From candybar with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) protected InputStream getContactPhotoStream(Uri uri) { ContentResolver res = context.getContentResolver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { return ContactsContract.Contacts.openContactPhotoInputStream(res, uri, true); } else { return ContactsContract.Contacts.openContactPhotoInputStream(res, uri); } }
Example #20
Source File: ContactAccessorSdk5.java From cordova-android-chromeview with Apache License 2.0 | 5 votes |
/** * Create a ContactName JSONObject * @param cursor the current database row * @return a JSONObject representing a ContactName */ private JSONObject nameQuery(Cursor cursor) { JSONObject contactName = new JSONObject(); try { String familyName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME)); String givenName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME)); String middleName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME)); String honorificPrefix = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.PREFIX)); String honorificSuffix = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.SUFFIX)); // Create the formatted name StringBuffer formatted = new StringBuffer(""); if (honorificPrefix != null) { formatted.append(honorificPrefix + " "); } if (givenName != null) { formatted.append(givenName + " "); } if (middleName != null) { formatted.append(middleName + " "); } if (familyName != null) { formatted.append(familyName); } if (honorificSuffix != null) { formatted.append(" " + honorificSuffix); } contactName.put("familyName", familyName); contactName.put("givenName", givenName); contactName.put("middleName", middleName); contactName.put("honorificPrefix", honorificPrefix); contactName.put("honorificSuffix", honorificSuffix); contactName.put("formatted", formatted); } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); } return contactName; }
Example #21
Source File: ContactsCursorLoader.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private Cursor getGroupsCursor() { MatrixCursor groupContacts = new MatrixCursor(CONTACT_PROJECTION); try (GroupDatabase.Reader reader = DatabaseFactory.getGroupDatabase(getContext()).getGroupsFilteredByTitle(filter, flagSet(mode, DisplayMode.FLAG_INACTIVE_GROUPS))) { GroupDatabase.GroupRecord groupRecord; while ((groupRecord = reader.getNext()) != null) { groupContacts.addRow(new Object[] { groupRecord.getRecipientId().serialize(), groupRecord.getTitle(), groupRecord.getId(), ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM, "", ContactRepository.NORMAL_TYPE }); } } return groupContacts; }
Example #22
Source File: ContactsCursorLoader.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private Cursor getNewNumberCursor() { MatrixCursor newNumberCursor = new MatrixCursor(CONTACT_PROJECTION, 1); newNumberCursor.addRow(new Object[] { null, getUnknownContactTitle(), filter, ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM, "\u21e2", ContactRepository.NEW_PHONE_TYPE}); return newNumberCursor; }
Example #23
Source File: Organization.java From react-native-paged-contacts with MIT License | 5 votes |
@Override public void addCreationOp(ArrayList<ContentProviderOperation> ops) { ContentProviderOperation.Builder op = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) .withValue(ContactsContract.CommonDataKinds.Organization.COMPANY, organizationName) .withValue(ContactsContract.CommonDataKinds.Organization.DEPARTMENT, departmentName) .withValue(ContactsContract.CommonDataKinds.Organization.TITLE, jobTitle) .withValue(ContactsContract.CommonDataKinds.Organization.PHONETIC_NAME, phoneticOrganizationName); ops.add(op.build()); }
Example #24
Source File: ContactsOpsImpl.java From mobilecloud-15 with Apache License 2.0 | 5 votes |
/** * Register the ContentObserver. */ protected void registerContentObserver() { // Register a ContentObserver that's notified when Contacts // change (e.g., are inserted, modified, or deleted). getActivityContext().getContentResolver().registerContentObserver (ContactsContract.Contacts.CONTENT_URI, true, contactsChangeContentObserver); }
Example #25
Source File: ContactsProvider.java From react-native-contacts with MIT License | 5 votes |
public WritableArray getContactsByPhoneNumber(String phoneNumber) { Map<String, Contact> matchingContacts; { Cursor cursor = contentResolver.query( ContactsContract.Data.CONTENT_URI, FULL_PROJECTION.toArray(new String[FULL_PROJECTION.size()]), ContactsContract.CommonDataKinds.Phone.NUMBER + " LIKE ? OR " + ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER + " LIKE ?", new String[]{"%" + phoneNumber + "%", "%" + phoneNumber + "%"}, null ); try { matchingContacts = loadContactsFrom(cursor); } finally { if (cursor != null) { cursor.close(); } } } WritableArray contacts = Arguments.createArray(); for (Contact contact : matchingContacts.values()) { contacts.pushMap(contact.toMap()); } return contacts; }
Example #26
Source File: ContactOperations.java From ez-vcard-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public ContactOperations(Context context, String accountName, String accountType) { this.context = context; account = new NonEmptyContentValues(); account.put(ContactsContract.RawContacts.ACCOUNT_TYPE, accountType); account.put(ContactsContract.RawContacts.ACCOUNT_NAME, accountName); }
Example #27
Source File: ContactAccessorSdk5.java From showCaseCordova with Apache License 2.0 | 5 votes |
/** * Create a ContactField JSONObject * @param cursor the current database row * @return a JSONObject representing a ContactField */ private JSONObject websiteQuery(Cursor cursor) { JSONObject website = new JSONObject(); try { website.put("id", cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Website._ID))); website.put("pref", false); // Android does not store pref attribute website.put("value", cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Website.URL))); website.put("type", getContactType(cursor.getInt(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Website.TYPE)))); } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); } return website; }
Example #28
Source File: DirectoryHelperV1.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static Optional<AccountHolder> getOrCreateAccount(Context context) { AccountManager accountManager = AccountManager.get(context); Account[] accounts = accountManager.getAccountsByType(context.getPackageName()); Optional<AccountHolder> account; if (accounts.length == 0) account = createAccount(context); else account = Optional.of(new AccountHolder(accounts[0], false)); if (account.isPresent() && !ContentResolver.getSyncAutomatically(account.get().getAccount(), ContactsContract.AUTHORITY)) { ContentResolver.setSyncAutomatically(account.get().getAccount(), ContactsContract.AUTHORITY, true); } return account; }
Example #29
Source File: ContactsListActivity.java From Identiconizer with Apache License 2.0 | 5 votes |
private Cursor getContacts() { Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection = new String[]{ ContactsContract.Contacts._ID, "name_raw_contact_id", ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_THUMBNAIL_URI }; String selection = "in_visible_group = '1'"; if (Config.getInstance(this).shouldIgnoreContactVisibility()) selection = null; String sortOrder = "display_name COLLATE LOCALIZED ASC"; return getContentResolver().query(uri, projection, selection, null, sortOrder); }
Example #30
Source File: ContactAccessorSdk5.java From cordova-android-chromeview with Apache License 2.0 | 5 votes |
/** * Create a ContactField JSONObject * @param cursor the current database row * @return a JSONObject representing a ContactField */ private JSONObject imQuery(Cursor cursor) { JSONObject im = new JSONObject(); try { im.put("id", cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Im._ID))); im.put("pref", false); // Android does not store pref attribute im.put("value", cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA))); im.put("type", getImType(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Im.PROTOCOL)))); } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); } return im; }