當前位置: 首頁>>代碼示例>>Java>>正文


Java Data.CONTACT_ID屬性代碼示例

本文整理匯總了Java中android.provider.ContactsContract.Data.CONTACT_ID屬性的典型用法代碼示例。如果您正苦於以下問題:Java Data.CONTACT_ID屬性的具體用法?Java Data.CONTACT_ID怎麽用?Java Data.CONTACT_ID使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.provider.ContactsContract.Data的用法示例。


在下文中一共展示了Data.CONTACT_ID屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getContactLookupKeyByContactId

protected String getContactLookupKeyByContactId(String contactId) {
    if (!SafeSlinger.doesUserHavePermission(Manifest.permission.READ_CONTACTS)) {
        return null;
    }
    if (TextUtils.isEmpty(contactId)) {
        return null;
    }

    String where = Data.CONTACT_ID + " = ?";
    String[] whereParameters = new String[] {
        contactId
    };

    Cursor c = getContentResolver().query(Data.CONTENT_URI, null, where, whereParameters, null);
    if (c != null) {
        try {
            if (c.moveToFirst()) {
                String lookup = c.getString(c.getColumnIndexOrThrow(Data.LOOKUP_KEY));
                return lookup;
            }
        } finally {
            c.close();
        }
    }
    return null;
}
 
開發者ID:SafeSlingerProject,項目名稱:SafeSlinger-Android,代碼行數:26,代碼來源:BaseActivity.java

示例2: deleteMultipleContactsAtOnce

public void deleteMultipleContactsAtOnce(List<String> ids) {
	String select = Data.CONTACT_ID + " = ?";
	ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

	for (String id : ids) {
		String[] args = new String[] { id };
		ops.add(ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI).withSelection(select, args).build());
	}

	ContentResolver cr = ContactsManager.getInstance().getContentResolver();
	try {
		cr.applyBatch(ContactsContract.AUTHORITY, ops);
	} catch (Exception e) {
		Log.e(e);
	}
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:16,代碼來源:ContactsManager.java

示例3: getContactsCursor

private Cursor getContactsCursor(ContentResolver cr) {
	String req = "(" + Data.MIMETYPE + " = '" + CommonDataKinds.Phone.CONTENT_ITEM_TYPE
			+ "' AND " + CommonDataKinds.Phone.NUMBER + " IS NOT NULL "
			+ " OR (" + Data.MIMETYPE + " = '" + CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE
			+ "' AND " + CommonDataKinds.SipAddress.SIP_ADDRESS + " IS NOT NULL))";
	String[] projection = new String[] { Data.CONTACT_ID, Data.DISPLAY_NAME };
	String query = Data.DISPLAY_NAME + " IS NOT NULL AND (" + req + ")";

	Cursor cursor = cr.query(Data.CONTENT_URI, projection, query, null, " lower(" + Data.DISPLAY_NAME + ") COLLATE UNICODE ASC");
	if (cursor == null) {
		return cursor;
	}

	MatrixCursor result = new MatrixCursor(cursor.getColumnNames());
	Set<String> groupBy = new HashSet<String>();
	while (cursor.moveToNext()) {
	    String name = cursor.getString(cursor.getColumnIndex(Data.DISPLAY_NAME));
	    if (!groupBy.contains(name)) {
	    	groupBy.add(name);
	    	Object[] newRow = new Object[cursor.getColumnCount()];

	    	int contactID = cursor.getColumnIndex(Data.CONTACT_ID);
	    	int displayName = cursor.getColumnIndex(Data.DISPLAY_NAME);

	    	newRow[contactID] = cursor.getString(contactID);
	    	newRow[displayName] = cursor.getString(displayName);

	        result.addRow(newRow);
    	}
    }
	cursor.close();
	return result;
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:33,代碼來源:ContactsManager.java

示例4: getNameProjection

/**
 * Get the NAME_PROJECTION for PhoneNumberPicker.
 */
public static String[] getNameProjection() {
  String[] nameProjection = {
    Data.CONTACT_ID,
    ContactsContract.Contacts.DISPLAY_NAME,
    ContactsContract.Contacts.PHOTO_THUMBNAIL_URI,
    Phone.NUMBER,
  };
  return nameProjection;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:12,代碼來源:HoneycombMR1Util.java

示例5: queryStep2

private void queryStep2(List<PhoneBean> beans, HashMap<Long, PhoneBean> phones) {
	final String[] PROJ_DATA = new String[] {
		Data._ID,
		Data.CONTACT_ID,
		Data.DATA1,
	};
	Cursor dataCursor = getContentResolver().query(Data.CONTENT_URI,
			PROJ_DATA,
			Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
			null, DATA_QUERY_ORDER);
	long dataId, contactId;
	String number;
	PhoneBean bean;
	try {
		dataCursor.moveToPosition(-1);
		while(dataCursor.moveToNext()) {
			dataId = dataCursor.getLong(0);
			contactId = dataCursor.getLong(1);
			number = dataCursor.getString(2);
			bean = new PhoneBean(dataId, number);
			beans.add(bean);
			//same contactId save one phoneBean
			phones.put(contactId, bean);
		}
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		if(dataCursor != null) {
			dataCursor.close();
		}
	}
}
 
開發者ID:doubleDragon,項目名稱:ContactsTool,代碼行數:32,代碼來源:RemoveService.java

示例6: updateContactIdFromUri

public static void updateContactIdFromUri(Uri uri) {
    ContactDetailFragment.SelectedContactID = uri.getLastPathSegment();
    ContactDetailFragment.CONTACT_PHONE_QUERY_SELECTION = Data.CONTACT_ID + "=" + ContactDetailFragment.SelectedContactID;
}
 
開發者ID:aarya123,項目名稱:CampusFeedv2,代碼行數:4,代碼來源:ContactDetailFragment.java

示例7: queryStep1

private void queryStep1(HashMap<String, ArrayList<ContactBean>> contactsMap) {
	final String[] PROJ_DATA = new String[] {
		Data._ID,
		Data.CONTACT_ID,
		Data.DATA1,
		Contacts.DISPLAY_NAME
	};
	Cursor dataCursor = getContentResolver().query(Data.CONTENT_URI,
			PROJ_DATA,
			Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
			null, DATA_QUERY_ORDER);
	long dataId, contactId;
	String number, name;
	PhoneBean phoneBean;
	ContactBean contactBean;
	ArrayList<ContactBean> tempSameBeans;
	try {
		dataCursor.moveToPosition(-1);
		while(dataCursor.moveToNext()) {
			dataId = dataCursor.getLong(0);
			contactId = dataCursor.getLong(1);
			number = dataCursor.getString(2);
			name = dataCursor.getString(3);
			phoneBean = new PhoneBean(dataId, number);
			contactBean = new ContactBean(contactId, name);
			contactBean.addNumber(phoneBean);
			if(contactsMap.containsKey(name)) {
				tempSameBeans = contactsMap.get(name);
				if(!tempSameBeans.contains(contactBean)) {
					tempSameBeans.add(contactBean);
				}
			} else {
				tempSameBeans = new ArrayList<ContactBean>();
				tempSameBeans.add(contactBean);
				contactsMap.put(name, tempSameBeans);
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		if(dataCursor != null) {
			dataCursor.close();
		}
	}
}
 
開發者ID:doubleDragon,項目名稱:ContactsTool,代碼行數:45,代碼來源:RemoveService.java


注:本文中的android.provider.ContactsContract.Data.CONTACT_ID屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。