本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.Phone.TYPE_WORK属性的典型用法代码示例。如果您正苦于以下问题:Java Phone.TYPE_WORK属性的具体用法?Java Phone.TYPE_WORK怎么用?Java Phone.TYPE_WORK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.ContactsContract.CommonDataKinds.Phone
的用法示例。
在下文中一共展示了Phone.TYPE_WORK属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getListEntry
@Override
protected ListEntry getListEntry(Cursor c) {
int phoneType = Integer.parseInt(c.getString(3));
String type = "";
if (phoneType == Phone.TYPE_HOME) {
type = getString(R.string.home);
} else if (phoneType == Phone.TYPE_MOBILE) {
type = getString(R.string.cell);
} else if (phoneType == Phone.TYPE_WORK) {
type = getString(R.string.work);
} else {
type = getString(R.string.other);
}
return new ContactListEntry(c.getString(0), c.getInt(1), type, c.getString(2));
}
示例2: getPhoneTypeLabel
private String getPhoneTypeLabel(int type, String label) {
switch (type) {
case Phone.TYPE_HOME:
return getString(R.string.label_hometag);
case Phone.TYPE_WORK:
return getString(R.string.label_worktag);
case Phone.TYPE_MOBILE:
return getString(R.string.label_mobiletag);
case Phone.TYPE_OTHER:
return getString(R.string.label_othertag);
default:
return Phone.getTypeLabel(this.getResources(), type, label).toString();
}
}
示例3: getPhoneType
/**
* Converts a string from the W3C Contact API to it's Android int value.
* @param string
* @return Android int value
*/
private int getPhoneType(String string) {
int type = Phone.TYPE_OTHER;
if (string != null) {
String lowerType = string.toLowerCase(Locale.getDefault());
if ("home".equals(lowerType)) {
return Phone.TYPE_HOME;
}
else if ("mobile".equals(lowerType)) {
return Phone.TYPE_MOBILE;
}
else if ("work".equals(lowerType)) {
return Phone.TYPE_WORK;
}
else if ("work fax".equals(lowerType)) {
return Phone.TYPE_FAX_WORK;
}
else if ("home fax".equals(lowerType)) {
return Phone.TYPE_FAX_HOME;
}
else if ("fax".equals(lowerType)) {
return Phone.TYPE_FAX_WORK;
}
else if ("pager".equals(lowerType)) {
return Phone.TYPE_PAGER;
}
else if ("other".equals(lowerType)) {
return Phone.TYPE_OTHER;
}
else if ("car".equals(lowerType)) {
return Phone.TYPE_CAR;
}
else if ("company main".equals(lowerType)) {
return Phone.TYPE_COMPANY_MAIN;
}
else if ("isdn".equals(lowerType)) {
return Phone.TYPE_ISDN;
}
else if ("main".equals(lowerType)) {
return Phone.TYPE_MAIN;
}
else if ("other fax".equals(lowerType)) {
return Phone.TYPE_OTHER_FAX;
}
else if ("radio".equals(lowerType)) {
return Phone.TYPE_RADIO;
}
else if ("telex".equals(lowerType)) {
return Phone.TYPE_TELEX;
}
else if ("work mobile".equals(lowerType)) {
return Phone.TYPE_WORK_MOBILE;
}
else if ("work pager".equals(lowerType)) {
return Phone.TYPE_WORK_PAGER;
}
else if ("assistant".equals(lowerType)) {
return Phone.TYPE_ASSISTANT;
}
else if ("mms".equals(lowerType)) {
return Phone.TYPE_MMS;
}
else if ("callback".equals(lowerType)) {
return Phone.TYPE_CALLBACK;
}
else if ("tty ttd".equals(lowerType)) {
return Phone.TYPE_TTY_TDD;
}
return Phone.TYPE_CUSTOM;
}
return type;
}
示例4: getPhoneType
/**
* Converts a string from the W3C Contact API to it's Android int value.
* @param string
* @return Android int value
*/
private int getPhoneType(String string) {
int type = Phone.TYPE_OTHER;
if (string != null) {
String lowerType = string.toLowerCase(Locale.getDefault());
if ("home".equals(lowerType)) {
return Phone.TYPE_HOME;
}
else if ("mobile".equals(lowerType)) {
return Phone.TYPE_MOBILE;
}
else if ("work".equals(lowerType)) {
return Phone.TYPE_WORK;
}
else if ("work fax".equals(lowerType)) {
return Phone.TYPE_FAX_WORK;
}
else if ("home fax".equals(lowerType)) {
return Phone.TYPE_FAX_HOME;
}
else if ("fax".equals(lowerType)) {
return Phone.TYPE_FAX_WORK;
}
else if ("pager".equals(lowerType)) {
return Phone.TYPE_PAGER;
}
else if ("other".equals(lowerType)) {
return Phone.TYPE_OTHER;
}
else if ("car".equals(lowerType)) {
return Phone.TYPE_CAR;
}
else if ("company main".equals(lowerType)) {
return Phone.TYPE_COMPANY_MAIN;
}
else if ("isdn".equals(lowerType)) {
return Phone.TYPE_ISDN;
}
else if ("main".equals(lowerType)) {
return Phone.TYPE_MAIN;
}
else if ("other fax".equals(lowerType)) {
return Phone.TYPE_OTHER_FAX;
}
else if ("radio".equals(lowerType)) {
return Phone.TYPE_RADIO;
}
else if ("telex".equals(lowerType)) {
return Phone.TYPE_TELEX;
}
else if ("work mobile".equals(lowerType)) {
return Phone.TYPE_WORK_MOBILE;
}
else if ("work pager".equals(lowerType)) {
return Phone.TYPE_WORK_PAGER;
}
else if ("assistant".equals(lowerType)) {
return Phone.TYPE_ASSISTANT;
}
else if ("mms".equals(lowerType)) {
return Phone.TYPE_MMS;
}
else if ("callback".equals(lowerType)) {
return Phone.TYPE_CALLBACK;
}
else if ("tty ttd".equals(lowerType)) {
return Phone.TYPE_TTY_TDD;
}
else if ("custom".equals(lowerType)) {
return Phone.TYPE_CUSTOM;
}
}
return type;
}
示例5: getXWikiUser
/**
* Return a User object with data extracted from a contact stored
* in the local contacts database.
* <p>
* Because a contact is actually stored over several rows in the
* database, our query will return those multiple rows of information.
* We then iterate over the rows and build the User structure from
* what we find.
*
* @param context the Authenticator Activity context
* @param rawContactId the unique ID for the local contact
* @return a User object containing info on that contact
*/
public static XWikiUser getXWikiUser(Context context, long rawContactId) {
String firstName = null;
String lastName = null;
String fullName = null;
String cellPhone = null;
String homePhone = null;
String workPhone = null;
String email = null;
String serverId = null;
final ContentResolver resolver = context.getContentResolver();
final Cursor c =
resolver.query(DataQuery.CONTENT_URI, DataQuery.PROJECTION, DataQuery.SELECTION,
new String[]{String.valueOf(rawContactId)}, null);
try {
while (c.moveToNext()) {
final long id = c.getLong(DataQuery.COLUMN_ID);
final String mimeType = c.getString(DataQuery.COLUMN_MIMETYPE);
final String tempServerId = c.getString(DataQuery.COLUMN_SERVER_ID);
if (tempServerId != null) {
serverId = tempServerId;
}
final Uri uri = ContentUris.withAppendedId(Data.CONTENT_URI, id);
if (mimeType.equals(StructuredName.CONTENT_ITEM_TYPE)) {
lastName = c.getString(DataQuery.COLUMN_FAMILY_NAME);
firstName = c.getString(DataQuery.COLUMN_GIVEN_NAME);
//fullName = c.getString(DataQuery.COLUMN_FULL_NAME);
} else if (mimeType.equals(Phone.CONTENT_ITEM_TYPE)) {
final int type = c.getInt(DataQuery.COLUMN_PHONE_TYPE);
if (type == Phone.TYPE_MOBILE) {
cellPhone = c.getString(DataQuery.COLUMN_PHONE_NUMBER);
} else if (type == Phone.TYPE_HOME) {
homePhone = c.getString(DataQuery.COLUMN_PHONE_NUMBER);
} else if (type == Phone.TYPE_WORK) {
workPhone = c.getString(DataQuery.COLUMN_PHONE_NUMBER);
}
} else if (mimeType.equals(ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)) {
email = c.getString(DataQuery.COLUMN_EMAIL_ADDRESS);
}
} // while
} finally {
c.close();
}
// Now that we've extracted all the information we care about,
// create the actual User object.
XWikiUser wikiUser = new XWikiUser(serverId, null, firstName, lastName, email, cellPhone, null,
rawContactId, null, null, null, null, null, null);
return wikiUser;
}
示例6: getAndroidPhoneType
public static int getAndroidPhoneType(PhoneType phoneType) {
switch (phoneType) {
case TYPE_ASSISTANT:
return Phone.TYPE_ASSISTANT;
case TYPE_CALLBACK:
return Phone.TYPE_CALLBACK;
case TYPE_CAR:
return Phone.TYPE_CAR;
case TYPE_COMPANY_MAIN:
return Phone.TYPE_COMPANY_MAIN;
case TYPE_CUSTOM:
return Phone.TYPE_CUSTOM;
case TYPE_FAX_HOME:
return Phone.TYPE_FAX_HOME;
case TYPE_FAX_WORK:
return Phone.TYPE_FAX_WORK;
case TYPE_HOME:
return Phone.TYPE_HOME;
case TYPE_ISDN:
return Phone.TYPE_ISDN;
case TYPE_MAIN:
return Phone.TYPE_MAIN;
case TYPE_MMS:
return Phone.TYPE_MMS;
case TYPE_MOBILE:
return Phone.TYPE_MOBILE;
case TYPE_OTHER:
return Phone.TYPE_OTHER;
case TYPE_OTHER_FAX:
return Phone.TYPE_OTHER_FAX;
case TYPE_PAGER:
return Phone.TYPE_PAGER;
case TYPE_RADIO:
return Phone.TYPE_RADIO;
case TYPE_TELEX:
return Phone.TYPE_TELEX;
case TYPE_TTY_TDD:
return Phone.TYPE_TTY_TDD;
case TYPE_WORK:
return Phone.TYPE_WORK;
case TYPE_WORK_MOBILE:
return Phone.TYPE_WORK_MOBILE;
case TYPE_WORK_PAGER:
return Phone.TYPE_WORK_PAGER;
default:
return Phone.TYPE_HOME;
}
}
示例7: getPhoneType
public static PhoneType getPhoneType(int androidPhoneType) {
switch (androidPhoneType) {
case Phone.TYPE_ASSISTANT:
return PhoneType.TYPE_ASSISTANT;
case Phone.TYPE_CALLBACK:
return PhoneType.TYPE_CALLBACK;
case Phone.TYPE_CAR:
return PhoneType.TYPE_CAR;
case Phone.TYPE_COMPANY_MAIN:
return PhoneType.TYPE_COMPANY_MAIN;
case Phone.TYPE_CUSTOM:
return PhoneType.TYPE_CUSTOM;
case Phone.TYPE_FAX_HOME:
return PhoneType.TYPE_FAX_HOME;
case Phone.TYPE_FAX_WORK:
return PhoneType.TYPE_FAX_WORK;
case Phone.TYPE_HOME:
return PhoneType.TYPE_HOME;
case Phone.TYPE_ISDN:
return PhoneType.TYPE_ISDN;
case Phone.TYPE_MAIN:
return PhoneType.TYPE_MAIN;
case Phone.TYPE_MMS:
return PhoneType.TYPE_MMS;
case Phone.TYPE_MOBILE:
return PhoneType.TYPE_MOBILE;
case Phone.TYPE_OTHER:
return PhoneType.TYPE_OTHER;
case Phone.TYPE_OTHER_FAX:
return PhoneType.TYPE_OTHER_FAX;
case Phone.TYPE_PAGER:
return PhoneType.TYPE_PAGER;
case Phone.TYPE_RADIO:
return PhoneType.TYPE_RADIO;
case Phone.TYPE_TELEX:
return PhoneType.TYPE_TELEX;
case Phone.TYPE_TTY_TDD:
return PhoneType.TYPE_TTY_TDD;
case Phone.TYPE_WORK:
return PhoneType.TYPE_WORK;
case Phone.TYPE_WORK_MOBILE:
return PhoneType.TYPE_WORK_MOBILE;
case Phone.TYPE_WORK_PAGER:
return PhoneType.TYPE_WORK_PAGER;
default:
return PhoneType.TYPE_HOME;
}
}
示例8: populatePhoneNumbers
protected void populatePhoneNumbers(Contact c) throws RemoteException {
@Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] { Phone.TYPE, Phone.LABEL, Phone.NUMBER, Phone.IS_SUPER_PRIMARY },
Phone.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(c.getLocalID()), Phone.CONTENT_ITEM_TYPE }, null);
while (cursor != null && cursor.moveToNext()) {
ezvcard.property.Telephone number = new ezvcard.property.Telephone(cursor.getString(2));
switch (cursor.getInt(0)) {
case Phone.TYPE_HOME:
number.addType(TelephoneType.HOME);
break;
case Phone.TYPE_MOBILE:
number.addType(TelephoneType.CELL);
break;
case Phone.TYPE_WORK:
number.addType(TelephoneType.WORK);
break;
case Phone.TYPE_FAX_WORK:
number.addType(TelephoneType.FAX);
number.addType(TelephoneType.WORK);
break;
case Phone.TYPE_FAX_HOME:
number.addType(TelephoneType.FAX);
number.addType(TelephoneType.HOME);
break;
case Phone.TYPE_PAGER:
number.addType(TelephoneType.PAGER);
break;
case Phone.TYPE_CALLBACK:
number.addType(Contact.PHONE_TYPE_CALLBACK);
break;
case Phone.TYPE_CAR:
number.addType(TelephoneType.CAR);
break;
case Phone.TYPE_COMPANY_MAIN:
number.addType(Contact.PHONE_TYPE_COMPANY_MAIN);
break;
case Phone.TYPE_ISDN:
number.addType(TelephoneType.ISDN);
break;
case Phone.TYPE_MAIN:
number.addType(TelephoneType.PREF);
break;
case Phone.TYPE_OTHER_FAX:
number.addType(TelephoneType.FAX);
break;
case Phone.TYPE_RADIO:
number.addType(Contact.PHONE_TYPE_RADIO);
break;
case Phone.TYPE_TELEX:
number.addType(TelephoneType.TEXTPHONE);
break;
case Phone.TYPE_TTY_TDD:
number.addType(TelephoneType.TEXT);
break;
case Phone.TYPE_WORK_MOBILE:
number.addType(TelephoneType.CELL);
number.addType(TelephoneType.WORK);
break;
case Phone.TYPE_WORK_PAGER:
number.addType(TelephoneType.PAGER);
number.addType(TelephoneType.WORK);
break;
case Phone.TYPE_ASSISTANT:
number.addType(Contact.PHONE_TYPE_ASSISTANT);
break;
case Phone.TYPE_MMS:
number.addType(Contact.PHONE_TYPE_MMS);
break;
case Phone.TYPE_CUSTOM:
String customType = cursor.getString(1);
if (!StringUtils.isEmpty(customType))
number.addType(TelephoneType.get(labelToXName(customType)));
}
if (cursor.getInt(3) != 0) // IS_PRIMARY
number.addType(TelephoneType.PREF);
c.getPhoneNumbers().add(number);
}
}
示例9: buildPhoneNumber
protected Builder buildPhoneNumber(Builder builder, Telephone number) {
int typeCode = Phone.TYPE_OTHER;
String typeLabel = null;
boolean is_primary = false;
Set<TelephoneType> types = number.getTypes();
// preferred number?
if (types.contains(TelephoneType.PREF))
is_primary = true;
// 1 Android type <-> 2 VCard types: fax, cell, pager
if (types.contains(TelephoneType.FAX)) {
if (types.contains(TelephoneType.HOME))
typeCode = Phone.TYPE_FAX_HOME;
else if (types.contains(TelephoneType.WORK))
typeCode = Phone.TYPE_FAX_WORK;
else
typeCode = Phone.TYPE_OTHER_FAX;
} else if (types.contains(TelephoneType.CELL)) {
if (types.contains(TelephoneType.WORK))
typeCode = Phone.TYPE_WORK_MOBILE;
else
typeCode = Phone.TYPE_MOBILE;
} else if (types.contains(TelephoneType.PAGER)) {
if (types.contains(TelephoneType.WORK))
typeCode = Phone.TYPE_WORK_PAGER;
else
typeCode = Phone.TYPE_PAGER;
// types with 1:1 translation
} else if (types.contains(TelephoneType.HOME)) {
typeCode = Phone.TYPE_HOME;
} else if (types.contains(TelephoneType.WORK)) {
typeCode = Phone.TYPE_WORK;
} else if (types.contains(Contact.PHONE_TYPE_CALLBACK)) {
typeCode = Phone.TYPE_CALLBACK;
} else if (types.contains(TelephoneType.CAR)) {
typeCode = Phone.TYPE_CAR;
} else if (types.contains(Contact.PHONE_TYPE_COMPANY_MAIN)) {
typeCode = Phone.TYPE_COMPANY_MAIN;
} else if (types.contains(TelephoneType.ISDN)) {
typeCode = Phone.TYPE_ISDN;
} else if (types.contains(TelephoneType.PREF)) {
typeCode = Phone.TYPE_MAIN;
} else if (types.contains(Contact.PHONE_TYPE_RADIO)) {
typeCode = Phone.TYPE_RADIO;
} else if (types.contains(TelephoneType.TEXTPHONE)) {
typeCode = Phone.TYPE_TELEX;
} else if (types.contains(TelephoneType.TEXT)) {
typeCode = Phone.TYPE_TTY_TDD;
} else if (types.contains(Contact.PHONE_TYPE_ASSISTANT)) {
typeCode = Phone.TYPE_ASSISTANT;
} else if (types.contains(Contact.PHONE_TYPE_MMS)) {
typeCode = Phone.TYPE_MMS;
} else if (!types.isEmpty()) {
TelephoneType type = types.iterator().next();
typeCode = Phone.TYPE_CUSTOM;
typeLabel = xNameToLabel(type.getValue());
}
builder = builder
.withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
.withValue(Phone.NUMBER, number.getText())
.withValue(Phone.TYPE, typeCode)
.withValue(Phone.IS_PRIMARY, is_primary ? 1 : 0)
.withValue(Phone.IS_SUPER_PRIMARY, is_primary ? 1 : 0);
if (typeLabel != null)
builder = builder.withValue(Phone.LABEL, typeLabel);
return builder;
}
示例10: createContacts
private void createContacts(final int count) {
Random random = new Random(System.currentTimeMillis());
String[] numberSet = new String[count / 2];
generateNumbers(numberSet, random);
int[] numberTypeSet = new int[] {
Phone.TYPE_MOBILE,
Phone.TYPE_HOME,
Phone.TYPE_WORK,
Phone.TYPE_FAX_WORK,
Phone.TYPE_COMPANY_MAIN,
};
ArrayList<ArrayList<ContentProviderOperation>> batchGroup = new ArrayList<>();
ArrayList<ContentProviderOperation> batchOps = new ArrayList<>(BATCH_OPERATIONS_MAX + 10);
for (int i = 0; i < count; i++) {
int starred = (random.nextInt(10) == 3 ? 1 : 0);
int rawContactInsertIndex = batchOps.size();
batchOps.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
.withValue(RawContacts.STARRED, starred)
.withValue(RawContacts.ACCOUNT_TYPE, ACCOUNT_TYPE)
.withValue(RawContacts.ACCOUNT_NAME, ACCOUNT_NAME)
.build());
String contactName = CONTACT_NAME_PREFIX + String.format(Locale.US, "%04d", i + 1);
batchOps.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
.withValue(StructuredName.DISPLAY_NAME, contactName)
.build());
final int numberCount = 1 + random.nextInt(5);
for (int k = 0; k < numberCount; k++) {
String number = numberSet[random.nextInt(numberSet.length)];
int numberType = numberTypeSet[random.nextInt(numberTypeSet.length)];
batchOps.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
.withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
.withValue(Phone.NUMBER, number)
.withValue(Phone.TYPE, numberType)
.build());
}
if (batchOps.size() > BATCH_OPERATIONS_MAX) {
batchGroup.add(batchOps);
batchOps = new ArrayList<>(BATCH_OPERATIONS_MAX + 10);
}
}
if (batchOps.size() > 0) {
batchGroup.add(batchOps);
}
try {
for (ArrayList<ContentProviderOperation> ops : batchGroup) {
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
}
} catch (RemoteException | OperationApplicationException e) {
e.printStackTrace();
}
}