本文整理汇总了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);
}
示例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);
}
示例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();
}
示例4: getPhoneType
/**
* Get Phone.CONTENT_ITEM_TYPE.
*/
public static String getPhoneType() {
return Phone.CONTENT_ITEM_TYPE;
}
示例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);
}
示例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;
}
}