本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.StructuredName类的典型用法代码示例。如果您正苦于以下问题:Java StructuredName类的具体用法?Java StructuredName怎么用?Java StructuredName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StructuredName类属于android.provider.ContactsContract.CommonDataKinds包,在下文中一共展示了StructuredName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addContact
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
public static void addContact(String name, String number)
{
ContentValues values = new ContentValues();
//������RawContacts.CONTENT_URIִ��һ����ֵ���룬Ŀ���ǻ�ȡϵͳ���ص�rawContactId
Uri rawContactUri = m_context.getContentResolver().insert(RawContacts.CONTENT_URI, values);
long rawContactId = ContentUris.parseId(rawContactUri);
//��data�������������
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);//��������
values.put(StructuredName.GIVEN_NAME, name);
m_context.getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
//��data�����绰����
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
values.put(Phone.NUMBER, number);
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
m_context.getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
}
示例2: changeContact
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
public static void changeContact(String name, String number, String ContactId)
{
Log.i("huahua", name);
ContentValues values = new ContentValues();
// ��������
values.put(StructuredName.GIVEN_NAME, name);
m_context.getContentResolver().update(ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + "=?",
new String[] { ContactId,StructuredName.CONTENT_ITEM_TYPE });
//���µ绰
values.clear();
values.put(ContactsContract.CommonDataKinds.Phone.NUMBER, number);
m_context.getContentResolver().update(ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + "=?",
new String[] { ContactId,Phone.CONTENT_ITEM_TYPE});
}
示例3: containsNonEmptyName
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
private boolean containsNonEmptyName(final ContentValues contentValues) {
final String familyName = contentValues.getAsString(StructuredName.FAMILY_NAME);
final String middleName = contentValues.getAsString(StructuredName.MIDDLE_NAME);
final String givenName = contentValues.getAsString(StructuredName.GIVEN_NAME);
final String prefix = contentValues.getAsString(StructuredName.PREFIX);
final String suffix = contentValues.getAsString(StructuredName.SUFFIX);
final String phoneticFamilyName =
contentValues.getAsString(StructuredName.PHONETIC_FAMILY_NAME);
final String phoneticMiddleName =
contentValues.getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
final String phoneticGivenName =
contentValues.getAsString(StructuredName.PHONETIC_GIVEN_NAME);
final String displayName = contentValues.getAsString(StructuredName.DISPLAY_NAME);
return !(TextUtils.isEmpty(familyName) && TextUtils.isEmpty(middleName) &&
TextUtils.isEmpty(givenName) && TextUtils.isEmpty(prefix) &&
TextUtils.isEmpty(suffix) && TextUtils.isEmpty(phoneticFamilyName) &&
TextUtils.isEmpty(phoneticMiddleName) && TextUtils.isEmpty(phoneticGivenName) &&
TextUtils.isEmpty(displayName));
}
示例4: testVCardNameFieldFromDisplayName
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
@Test
public void testVCardNameFieldFromDisplayName() {
final ArrayList<ContentValues> contentList = new ArrayList<>();
final ContentValues values = new ContentValues();
values.put(StructuredName.DISPLAY_NAME, "ने");
contentList.add(values);
final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_DEFAULT);
builder.appendNameProperties(contentList);
final String actual = builder.toString();
final String expectedCommon = ";CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:" +
"=E0=A4=A8=E0=A5=87";
final String expectedName = "N" + expectedCommon + ";;;;";
final String expectedFullName = "FN" + expectedCommon;
assertTrue("Actual value:\n" + actual + " expected to contain\n" + expectedName +
"\nbut does not.", actual.contains(expectedName));
assertTrue("Actual value:\n" + actual + " expected to contain\n" + expectedFullName +
"\nbut does not.", actual.contains(expectedFullName));
}
示例5: testAppendNameProperties_name
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
@Test
public void testAppendNameProperties_name() {
final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_V30_GENERIC,
VCardConfig.DEFAULT_EXPORT_CHARSET);
final ContentValues cv = new ContentValues();
final List<ContentValues> group = new ArrayList<>();
cv.put(ContactsContract.Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
cv.put(Email.DATA1, "Spruce Grouse");
cv.put(Email.DATA2, "Spruce");
cv.put(Email.DATA3, "Grouse");
group.add(cv);
final String card = builder.appendNameProperties(group).toString();
assertEquals(NAME_CARD, card);
}
示例6: getContactsName
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
public static List<String> getContactsName(ContentResolver contentResolver) {
List<String> listPeopleName = null;
Cursor cursor = null;
try {
cursor = contentResolver.query(
ContactsContract.Contacts.CONTENT_URI,
new String[] { ContactsContract.Contacts.DISPLAY_NAME },
null, null, StructuredName.SORT_KEY_PRIMARY);
listPeopleName = new ArrayList<String>();
while (cursor.moveToNext()) {
listPeopleName
.add(cursor.getString(cursor
.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
return listPeopleName;
}
示例7: initColumnNameConstantsMap
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
private void initColumnNameConstantsMap() {
if (mColumnNameConstantsMap != null) {
return;
}
mColumnNameConstantsMap = new HashMap<String, String>();
mColumnNameConstantsMap.put("name", StructuredName.DISPLAY_NAME);
mColumnNameConstantsMap.put("givenname", StructuredName.GIVEN_NAME);
mColumnNameConstantsMap.put("familyname", StructuredName.FAMILY_NAME);
mColumnNameConstantsMap.put("honorificprefix", StructuredName.PREFIX);
mColumnNameConstantsMap.put("honorificsuffix", StructuredName.SUFFIX);
mColumnNameConstantsMap.put("additionalname", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("nickname", Nickname.NAME);
mColumnNameConstantsMap.put("adr", StructuredPostal.STREET);
mColumnNameConstantsMap.put("email", Email.ADDRESS);
mColumnNameConstantsMap.put("url", Website.URL);
mColumnNameConstantsMap.put("category", GroupMembership.GROUP_ROW_ID);
mColumnNameConstantsMap.put("tel", Phone.NUMBER);
mColumnNameConstantsMap.put("org", Organization.COMPANY);
mColumnNameConstantsMap.put("jobTitle", Organization.TITLE);
mColumnNameConstantsMap.put("note", Note.NOTE);
mColumnNameConstantsMap.put("impp", Im.DATA);
mColumnNameConstantsMap.put("sex", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("genderidentity", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("key", CUSTOM_DATA_COLUMN);
}
示例8: initMimeTypeConstantsMap
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
private void initMimeTypeConstantsMap() {
if (mMimeTypeConstantsMap != null) {
return;
}
mMimeTypeConstantsMap = new HashMap<String, String>();
mMimeTypeConstantsMap.put("name", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("givenname", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("familyname", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("honorificprefix", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("honorificsuffix", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("additionalname", MIMETYPE_ADDITIONAL_NAME);
mMimeTypeConstantsMap.put("nickname", Nickname.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("email", Email.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("url", Website.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("category", GroupMembership.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("tel", Phone.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("org", Organization.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("jobTitle", Organization.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("note", Note.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("impp", Im.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("sex", MIMETYPE_SEX);
mMimeTypeConstantsMap.put("genderidentity", MIMETYPE_GENDER_IDENTITY);
mMimeTypeConstantsMap.put("key", MIMETYPE_KEY);
}
示例9: addContact
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
/**
* Synchronously insert a contact with the designated @name into
* the ContactsContentProvider. This code is explained at
* http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html.
*/
private void addContact(String name,
List<ContentProviderOperation> cpops) {
final int position = cpops.size();
// First part of operation.
cpops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
.withValue(RawContacts.ACCOUNT_TYPE,
mOps.getAccountType())
.withValue(RawContacts.ACCOUNT_NAME,
mOps.getAccountName())
.withValue(Contacts.STARRED,
1)
.build());
// Second part of operation.
cpops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
.withValueBackReference(Data.RAW_CONTACT_ID,
position)
.withValue(Data.MIMETYPE,
StructuredName.CONTENT_ITEM_TYPE)
.withValue(StructuredName.DISPLAY_NAME,
name)
.build());
}
示例10: addName
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
/**
* Adds a contact name. We can take either a full name ("Bob Smith") or separated
* first-name and last-name ("Bob" and "Smith").
*
* @param fullName The full name of the contact - typically from an edit form
* Can be null if firstName/lastName are specified.
* @param firstName The first name of the contact - can be null if fullName
* is specified.
* @param lastName The last name of the contact - can be null if fullName
* is specified.
* @return instance of ContactOperations
*/
public ContactOperations addName(String fullName, String firstName, String lastName) {
mValues.clear();
if (!TextUtils.isEmpty(fullName)) {
mValues.put(StructuredName.DISPLAY_NAME, fullName);
mValues.put(StructuredName.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
} else {
if (!TextUtils.isEmpty(firstName)) {
mValues.put(StructuredName.GIVEN_NAME, firstName);
mValues.put(StructuredName.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
}
if (!TextUtils.isEmpty(lastName)) {
mValues.put(StructuredName.FAMILY_NAME, lastName);
mValues.put(StructuredName.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
}
}
if (mValues.size() > 0) {
addInsertOp();
}
return this;
}
示例11: populateStructuredName
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
private void populateStructuredName(Contact c) throws RemoteException {
@Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] {
/* 0 */ StructuredName.DISPLAY_NAME, StructuredName.PREFIX, StructuredName.GIVEN_NAME,
/* 3 */ StructuredName.MIDDLE_NAME, StructuredName.FAMILY_NAME, StructuredName.SUFFIX,
/* 6 */ StructuredName.PHONETIC_GIVEN_NAME, StructuredName.PHONETIC_MIDDLE_NAME, StructuredName.PHONETIC_FAMILY_NAME
}, StructuredName.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(c.getLocalID()), StructuredName.CONTENT_ITEM_TYPE }, null);
if (cursor != null && cursor.moveToNext()) {
c.setDisplayName(cursor.getString(0));
c.setPrefix(cursor.getString(1));
c.setGivenName(cursor.getString(2));
c.setMiddleName(cursor.getString(3));
c.setFamilyName(cursor.getString(4));
c.setSuffix(cursor.getString(5));
c.setPhoneticGivenName(cursor.getString(6));
c.setPhoneticMiddleName(cursor.getString(7));
c.setPhoneticFamilyName(cursor.getString(8));
}
}
示例12: addName
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
@Override
public boolean addName(ContactStruct contact, Cursor names) {
String display = names.getString(names.getColumnIndex(StructuredName.DISPLAY_NAME));
String family = names.getString(names.getColumnIndex(StructuredName.FAMILY_NAME));
String given = names.getString(names.getColumnIndex(StructuredName.GIVEN_NAME));
String middle = names.getString(names.getColumnIndex(StructuredName.MIDDLE_NAME));
String prefix = names.getString(names.getColumnIndex(StructuredName.PREFIX));
String suffix = names.getString(names.getColumnIndex(StructuredName.SUFFIX));
boolean super_primary = (names.getInt(names
.getColumnIndexOrThrow(StructuredName.IS_SUPER_PRIMARY)) != 0);
if (!TextUtils.isEmpty(display) && isNameNew(contact, display, super_primary)) {
contact.name = new Name(family, given, middle, prefix, suffix,
Name.NAME_ORDER_TYPE_ENGLISH);
return true;
}
return false;
}
示例13: AddContact
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
public static void AddContact(ContentResolver mResolver, String name, String number, String groupName)
{
Log.i("hoperun", "name= " + name + ";number=" + number);
if (!queryFromContact(mResolver, name, number))
{
ContentValues values = new ContentValues();
// 首先向RawContacts.CONTENT_URI执行一个空值插入,目的是获取系统返回的rawContactId
Uri rawContactUri = mResolver.insert(RawContacts.CONTENT_URI, values);
if (rawContactUri != null)
{
long rawContactId = ContentUris.parseId(rawContactUri);
// 往data表插入姓名数据
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);// 内容类型
values.put(StructuredName.GIVEN_NAME, name);
mResolver.insert(ContactsContract.Data.CONTENT_URI, values);
// 往data表插入电话数据
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
values.put(Phone.NUMBER, number);
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
mResolver.insert(ContactsContract.Data.CONTENT_URI, values);
}
else
{
Log.i("hoperun", "name= " + name + ";number=" + number);
}
}
else
{
Log.i("hoperun", "repeat name= " + name + ";number=" + number);
}
}
示例14: insertContact
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
/**
* 往手机通讯录插入联系人
*
* @param ct
* @param name
* @param tel
* @param email
*/
public static void insertContact(Context ct, String name, String tel, String email) {
ContentValues values = new ContentValues();
// 首先向RawContacts.CONTENT_URI执行一个空值插入,目的是获取系统返回的rawContactId
Uri rawContactUri = ct.getContentResolver().insert(RawContacts.CONTENT_URI, values);
long rawContactId = ContentUris.parseId(rawContactUri);
// 往data表入姓名数据
if (!TextUtils.isEmpty(tel)) {
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);// 内容类型
values.put(StructuredName.GIVEN_NAME, name);
ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
}
// 往data表入电话数据
if (!TextUtils.isEmpty(tel)) {
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);// 内容类型
values.put(Phone.NUMBER, tel);
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
}
// 往data表入Email数据
if (!TextUtils.isEmpty(email)) {
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);// 内容类型
values.put(Email.DATA, email);
values.put(Email.TYPE, Email.TYPE_WORK);
ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
}
}
示例15: fillFromCursor
import android.provider.ContactsContract.CommonDataKinds.StructuredName; //导入依赖的package包/类
private void fillFromCursor() {
namePrefix = getString(StructuredName.PREFIX);
givenName = getString(StructuredName.GIVEN_NAME);
middleName = getString(StructuredName.MIDDLE_NAME);
familyName = getString(StructuredName.FAMILY_NAME);
nameSuffix = getString(StructuredName.SUFFIX);
phoneticGivenName = getString(StructuredName.PHONETIC_GIVEN_NAME);
phoneticMiddleName = getString(StructuredName.PHONETIC_MIDDLE_NAME);
phoneticFamilyName = getString(StructuredName.PHONETIC_FAMILY_NAME);
}