本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.Nickname类的典型用法代码示例。如果您正苦于以下问题:Java Nickname类的具体用法?Java Nickname怎么用?Java Nickname使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Nickname类属于android.provider.ContactsContract.CommonDataKinds包,在下文中一共展示了Nickname类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initColumnNameConstantsMap
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的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);
}
示例2: initMimeTypeConstantsMap
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的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);
}
示例3: addNickname
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
public ContactOperations addNickname(String nickname, int type,
String label, boolean isPrimary, boolean isSuperPrimary) {
mValues.clear();
if (!TextUtils.isEmpty(nickname)) {
mValues.put(Nickname.NAME, nickname);
mValues.put(Nickname.TYPE, type);
mValues.put(Nickname.MIMETYPE, Nickname.CONTENT_ITEM_TYPE);
if (!TextUtils.isEmpty(label)) {
mValues.put(Nickname.LABEL, label);
}
if (isSuperPrimary) {
mValues.put(Email.IS_SUPER_PRIMARY, 1);
}
if (isPrimary) {
mValues.put(Email.IS_PRIMARY, 1);
}
addInsertOp();
}
return this;
}
示例4: getAndroidNicknameType
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static int getAndroidNicknameType(NicknameType type) {
switch (type) {
case TYPE_CUSTOM:
return Nickname.TYPE_CUSTOM;
case TYPE_DEFAULT:
return Nickname.TYPE_DEFAULT;
case TYPE_INITIALS:
return Nickname.TYPE_INITIALS;
case TYPE_MAIDEN_NAME:
return Nickname.TYPE_MAINDEN_NAME;
case TYPE_OTHER_NAME:
return Nickname.TYPE_OTHER_NAME;
case TYPE_SHORT_NAME:
return Nickname.TYPE_SHORT_NAME;
default:
return Nickname.TYPE_DEFAULT;
}
}
示例5: getNicknameType
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static NicknameType getNicknameType(int androidType) {
switch (androidType) {
case Nickname.TYPE_CUSTOM:
return NicknameType.TYPE_CUSTOM;
case Nickname.TYPE_DEFAULT:
return NicknameType.TYPE_DEFAULT;
case Nickname.TYPE_INITIALS:
return NicknameType.TYPE_INITIALS;
case Nickname.TYPE_MAINDEN_NAME:
return NicknameType.TYPE_MAIDEN_NAME;
case Nickname.TYPE_OTHER_NAME:
return NicknameType.TYPE_OTHER_NAME;
case Nickname.TYPE_SHORT_NAME:
return NicknameType.TYPE_SHORT_NAME;
default:
return NicknameType.TYPE_DEFAULT;
}
}
示例6: Assets
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
public Assets(Context context, long contactId) {
this.context = context;
cursor = context.getContentResolver().query(
Data.CONTENT_URI,
new String[]{Data._ID,
Data.RAW_CONTACT_ID, Data.MIMETYPE, Data.IS_PRIMARY,
Data.IS_SUPER_PRIMARY, Data.DATA_VERSION, Data.DATA1,
Data.DATA2, Data.DATA3, Data.DATA4, Data.DATA5, Data.DATA6,
Data.DATA7, Data.DATA8, Data.DATA9, Data.DATA10, Data.DATA11,
Data.DATA12, Data.DATA13, Data.DATA14, Data.DATA15, Data.SYNC1,
Data.SYNC2, Data.SYNC3, Data.SYNC4, },
Data.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + " IN ( ?, ?, ?, ?, ?, ? )",
new String[]{
String.valueOf(contactId),
Nickname.CONTENT_ITEM_TYPE,
Im.CONTENT_ITEM_TYPE,
Photo.CONTENT_ITEM_TYPE,
},
null);
//cursor.moveToFirst();
columnNames = cursor.getColumnNames();
}
示例7: contactByNickname
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
/**
* Lookup a contact by a given nickname.
*
* The returned contact will come with all known contact numbers and a
* lookup key.
*
* @param nickname
* @return A contact, or null if none found or on error.
*/
public Contact contactByNickname(String nickname) {
if (!contactsReadModuleInstalled()) return null;
final String[] projection = new String[] { Data.LOOKUP_KEY, DISPLAY_NAME, Nickname.NAME };
final String selection = Nickname.NAME + "=?" + AND + Data.MIMETYPE + "='"
+ Nickname.CONTENT_ITEM_TYPE + "'" + LIMIT_1;
final String[] selectionArgs = new String[] { nickname };
Cursor c = mContentResolver.query(MAXS_DATA_CONTENT_URI, projection, selection,
selectionArgs, null);
Contact contact = null;
if (c.moveToFirst()) {
String lookupKey = c.getString(c.getColumnIndexOrThrow(Data.LOOKUP_KEY));
String displayName = c.getString(c.getColumnIndexOrThrow(DISPLAY_NAME));
nickname = c.getString(c.getColumnIndexOrThrow(Nickname.NAME));
contact = new Contact(displayName, lookupKey);
contact.setNickname(nickname);
lookupContactNumbersFor(contact);
}
c.close();
return contact;
}
示例8: contactsByNickname
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
/**
* Get all matching contacts for a given nickname.
*
* The contacts will come with all known contact numbers and a lookup key.
*
* @param nickname
* @return A contact, or null if none found or on error.
*/
public Collection<Contact> contactsByNickname(String nickname) {
if (!contactsReadModuleInstalled()) return null;
final String[] projection = new String[] { Data.LOOKUP_KEY, DISPLAY_NAME, Nickname.NAME };
final String selection = Nickname.NAME + "=?" + AND + Data.MIMETYPE + "='"
+ Nickname.CONTENT_ITEM_TYPE + "'";
final String[] selectionArgs = new String[] { nickname };
Cursor c = mContentResolver.query(MAXS_DATA_CONTENT_URI, projection, selection,
selectionArgs, null);
Collection<Contact> contacts = new ArrayList<Contact>();
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
String lookupKey = c.getString(c.getColumnIndexOrThrow(Data.LOOKUP_KEY));
String displayName = c.getString(c.getColumnIndexOrThrow(DISPLAY_NAME));
nickname = c.getString(c.getColumnIndexOrThrow(Nickname.NAME));
Contact contact = new Contact(displayName, lookupKey);
contact.setNickname(nickname);
lookupContactNumbersFor(contact);
contacts.add(contact);
}
c.close();
return contacts;
}
示例9: getNicknamesValues
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
private void getNicknamesValues(final JSONArray nicknames, List<ContentValues> newContactValues) throws JSONException {
if (nicknames == null) {
return;
}
for (int i = 0; i < nicknames.length(); i++) {
ContentValues contentValues = new ContentValues();
contentValues.put(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE);
contentValues.put(Nickname.NAME, nicknames.getString(i));
contentValues.put(Nickname.TYPE, Nickname.TYPE_DEFAULT);
newContactValues.add(contentValues);
}
}
示例10: updateNickname
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
public ContactOperations updateNickname(String nickname, String label,
boolean isPrimary, boolean isSuperPrimary, Uri uri) {
mValues.clear();
mValues.put(Nickname.NAME, nickname);
mValues.put(Nickname.LABEL, label);
mValues.put(Nickname.IS_PRIMARY, isPrimary ? 1 : 0);
mValues.put(Nickname.IS_SUPER_PRIMARY, isSuperPrimary ? 1 : 0);
addUpdateOp(uri);
return this;
}
示例11: populateNickname
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
protected void populateNickname(Contact c) throws RemoteException {
@Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] { Nickname.NAME },
Nickname.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(c.getLocalID()), Nickname.CONTENT_ITEM_TYPE }, null);
if (cursor != null && cursor.moveToNext())
c.setNickName(cursor.getString(0));
}
示例12: byTypeId
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
/**
* Retrieve an nickname type for a given id.
* @param id The id in question.
* @return The resolved enum type, or null.
*/
@SuppressWarnings("deprecation")
private static Type byTypeId(int id) {
switch(id) {
case Nickname.TYPE_CUSTOM: return Type.CUSTOM;
case Nickname.TYPE_DEFAULT: return Type.DEFAULT;
case Nickname.TYPE_OTHER_NAME: return Type.OTHER_NAME;
case Nickname.TYPE_MAINDEN_NAME: return Type.MAIDEN_NAME;
case Nickname.TYPE_SHORT_NAME: return Type.SHORT_NAME;
case Nickname.TYPE_INITIALS: return Type.INITIALS;
}
return null;
}
示例13: cursorToHashMap
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
@Override
public void cursorToHashMap(Map<String, Object> contactsMap, Cursor c) {
// 获取当前行的 mimetype用于比较
String mimetype = c.getString(c
.getColumnIndex(ContactsContract.Data.MIMETYPE));
if (StructuredName.CONTENT_ITEM_TYPE.equals(mimetype)) {
contactsMap.put(LOGIC_FIELD_DISPLAYNAME,
c.getString(c.getColumnIndex(StructuredName.DISPLAY_NAME)));
nameQuery(contactsMap, c);
} else if (Event.CONTENT_ITEM_TYPE.equals(mimetype)) {
if (Event.TYPE_BIRTHDAY == c.getInt(c.getColumnIndex(Event.TYPE))) {
contactsMap.put(LOGIC_FIELD_BIRTHDAY,
c.getString(c.getColumnIndex(Event.START_DATE)));
}
} else if (Nickname.CONTENT_ITEM_TYPE.equals(mimetype)) {
contactsMap.put(LOGIC_FIELD_NICKNAME,
c.getString(c.getColumnIndex(Nickname.NAME)));
} else if (Note.CONTENT_ITEM_TYPE.equals(mimetype)) {
contactsMap.put(LOGIC_FIELD_NOTE,
c.getString(c.getColumnIndex(Note.NOTE)));
} else {
String logicField = LOGIC_FIELD_TO_CONTENT_TYPE_MAP
.getKeyByValue(mimetype);
if (LOGIC_CONTACT_MULTIPLE_VALUE_FIELDS.contains(logicField)) {
multipleValueFieldQuery(contactsMap, c, logicField);
}
}
}
示例14: buildNickName
import android.provider.ContactsContract.CommonDataKinds.Nickname; //导入依赖的package包/类
protected Builder buildNickName(Builder builder, String nickName) {
return builder
.withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
.withValue(Nickname.NAME, nickName);
}