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


Java Phone.CONTENT_ITEM_TYPE屬性代碼示例

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


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

示例1: updatePhone

private boolean updatePhone(PhoneData phone, String rawContactId, Context ctx) {

        // seek for raw contact + number = same
        String[] proj = new String[] {
                Phone.RAW_CONTACT_ID, Data.MIMETYPE, Phone.NUMBER
        };
        String where = Phone.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=? AND " + Phone.NUMBER
                + "=?";
        String[] args = new String[] {
                rawContactId, Phone.CONTENT_ITEM_TYPE, phone.data
        };
        ContentValues values = valuesPhone(phone);
        values.put(Phone.RAW_CONTACT_ID, rawContactId);

        return updateDataRow(ctx, proj, where, args, values);
    }
 
開發者ID:SafeSlingerProject,項目名稱:SafeSlinger-Android,代碼行數:16,代碼來源:ContactAccessorApi5.java

示例2: onCreateLoader

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] columns = {Phone._ID, Phone.DISPLAY_NAME_PRIMARY, Phone.DATA};
    String selection = Data.MIMETYPE + " = '" + Phone.CONTENT_ITEM_TYPE + "'";
    String orderBy = Phone.DISPLAY_NAME_PRIMARY + " ASC";
    return new CursorLoader(this, Phone.CONTENT_URI, columns, selection, null, orderBy);
}
 
開發者ID:Egorand,項目名稱:android-testing-runtime-permissions,代碼行數:7,代碼來源:MainActivity.java

示例3: lookupContactNumbersFor

/**
 * Lookup the numbers for a given contact.
 * 
 * Usually this is not needed because most methods already return the
 * contacts with all known contact numbers. Make sure to call
 * {@link #contactsReadModuleInstalled()} first.
 * 
 * @param contact
 */
public void lookupContactNumbersFor(Contact contact) {
	if (!contactsReadModuleInstalled()) return;

	String lookupKey = contact.getLookupKey();
	// @formatter:off
	final String[] projection = new String[] { 
			Phone.NUMBER,
			Phone.TYPE,
			Phone.LABEL,
			Phone.IS_SUPER_PRIMARY
			};
	// @formatter:on
	final String selection = ContactsContract.PhoneLookup.LOOKUP_KEY + "=?" + AND
			+ ContactsContract.Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'";
	final String[] selectionArgs = new String[] { lookupKey };
	Cursor c = mContentResolver.query(MAXS_DATA_CONTENT_URI, projection, selection,
			selectionArgs, null);

	for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
		String number = c.getString(c
				.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
		int type = c.getInt(c
				.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.TYPE));
		String label = c.getString(c
				.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.LABEL));
		boolean superPrimary = c
				.getInt(c
						.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY)) > 0 ? true
				: false;
		contact.addNumber(number, type, label, superPrimary);
	}
	c.close();
}
 
開發者ID:ProjectMAXS,項目名稱:maxs,代碼行數:42,代碼來源:ContactUtil.java

示例4: getPhoneType

/**
 * Get Phone.CONTENT_ITEM_TYPE.
 */
public static String getPhoneType() {
  return Phone.CONTENT_ITEM_TYPE;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:6,代碼來源:HoneycombMR1Util.java

示例5: createContactList

public List<String> createContactList(Cursor cursor) {
    if (cursor == null || cursor.getCount() == 0) {
        return Collections.<String>emptyList();
    }

    final int mimeTypeColumnIndex = cursor.getColumnIndex(ContactsContract.Data.MIMETYPE);
    final int lookupKeyColumnIndex = cursor.getColumnIndex(ContactsContract.Contacts
            .LOOKUP_KEY);
    final Map<String, List<ContentValues>> mapContactsData = new HashMap<>();
    while (cursor.moveToNext()) {
        final String mimeType = cursor.getString(mimeTypeColumnIndex);
        final ContentValues cv = new ContentValues();
        cv.put(ContactsContract.Data.MIMETYPE, mimeType);
        switch (mimeType) {
            case Phone.CONTENT_ITEM_TYPE:
                DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, Phone.TYPE);
                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Phone.LABEL);
                DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, Phone.IS_PRIMARY);
                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Phone.NUMBER);
                break;
            case StructuredName.CONTENT_ITEM_TYPE:
                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
                        StructuredName.DISPLAY_NAME);
                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
                        StructuredName.GIVEN_NAME);
                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
                        StructuredName.FAMILY_NAME);
                break;
            default:
                continue;
        }
        // Aggregate contacts based on their lookup key.
        final String lookupKey = cursor.getString(lookupKeyColumnIndex);
        List<ContentValues> contactDetails = mapContactsData.get(lookupKey);
        if (contactDetails == null) {
            contactDetails = new ArrayList<>();
            mapContactsData.put(lookupKey, contactDetails);
        }
        contactDetails.add(cv);
    }

    return processContactsMap(mapContactsData);
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:43,代碼來源:ContactsHelper.java

示例6: getNumberfromContact

private String getNumberfromContact(String contact, Boolean debugging)	{
	ContentResolver cr = getContentResolver();
	String result = null;
	boolean valid = false;	
	String val_num = null;
	int contact_id = 0;
       // Cursor1 search for valid Database Entries who matches the contact name
	Uri uri = ContactsContract.Contacts.CONTENT_URI;
	String[] projection = new String[]{	ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.HAS_PHONE_NUMBER };
	String selection = ContactsContract.Contacts.DISPLAY_NAME + "=?";
	String[] selectionArgs = new String[]{String.valueOf(contact)};
	String sortOrder = null;
	Cursor cursor1 = cr.query(uri, projection, selection, selectionArgs, sortOrder);

    if(cursor1.moveToFirst()){
    	if(cursor1.getInt(cursor1.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)) == 1){
    		contact_id = cursor1.getInt(cursor1.getColumnIndex(ContactsContract.Contacts._ID));
    		if (debugging)	{
        		Log.d(TAG, "C1 found Database ID: " + contact_id + " with Entry: " + cursor1.getString(cursor1.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
            }
            // Cursor 2 search for valid MOBILE Telephone numbers (selection = Phone.TYPE 2)
        	Uri uri2 = ContactsContract.Data.CONTENT_URI;	
        	String[] projection2 = new String[]{ Phone.NUMBER, Phone.TYPE };
        	String selection2 = Phone.CONTACT_ID + "=? AND " + Data.MIMETYPE + "=? AND " + Phone.TYPE + "=2";
    		String[] selectionArgs2 = new String[]{ String.valueOf(contact_id), Phone.CONTENT_ITEM_TYPE };
    		String sortOrder2 = Data.IS_PRIMARY + " desc"; 	
        	Cursor cursor2 = cr.query(uri2, projection2, selection2, selectionArgs2, sortOrder2);
            
        	if(cursor2.moveToFirst()){
                result = cursor2.getString(cursor2.getColumnIndex(Phone.NUMBER));
        		if (debugging)	{
                	Log.d(TAG, "C2 found number: " + result);
                }
            }
            cursor2.close();
        }
        cursor1.close();
    }
    if (result != null)	{
    	valid = isNumberValid(result);
    }
	if (!valid)	{
		if (debugging)	{
           	Log.d(TAG, "number seems invalid, try to resolve: " + result);
           }
		val_num = makeNumberValid(result);
		if (val_num != null)	{
			valid = true;
			result = val_num;
			if (debugging)	{
            	Log.d(TAG, "return modified number: " + result);
            }
		}
	}
    if (valid)	{
    	if (debugging)	{
           	Log.d(TAG, "return number: " + result);
           }
    	return result;
    } else	{
    	return null;
    }
}
 
開發者ID:try2codesecure,項目名稱:ShellMS,代碼行數:63,代碼來源:sendSMS.java


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