本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.GroupMembership类的典型用法代码示例。如果您正苦于以下问题:Java GroupMembership类的具体用法?Java GroupMembership怎么用?Java GroupMembership使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GroupMembership类属于android.provider.ContactsContract.CommonDataKinds包,在下文中一共展示了GroupMembership类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initColumnNameConstantsMap
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的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.GroupMembership; //导入依赖的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: getGroupContactIds
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
public GroupContactIds getGroupContactIds(Context context, ContactGroup group) {
final GroupContactIds contactIds = new GroupContactIds();
Cursor c = null;
switch (group.type) {
case GROUP:
c = context.getContentResolver().query(
Data.CONTENT_URI,
new String[] { GroupMembership.CONTACT_ID, GroupMembership.RAW_CONTACT_ID,
GroupMembership.GROUP_ROW_ID },
GroupMembership.GROUP_ROW_ID + " = ? AND " + GroupMembership.MIMETYPE + " = ?",
new String[] { String.valueOf(group._id), GroupMembership.CONTENT_ITEM_TYPE },
null);
break;
}
while (c != null && c.moveToNext()) {
contactIds.ids.add(c.getLong(0));
contactIds.rawIds.add(c.getLong(1));
}
if (c!=null) c.close();
return contactIds;
}
示例4: updateContactFromGroup
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
/**
* ������ϵ�����ڷ���
*
* @param groupID
* ��ǰ��ϵ������Ⱥ��
* @param contactID
* ��ϵ��ID
*/
public void updateContactFromGroup(int groupID, String contactID) {
ContentValues values = new ContentValues();
// ����Ⱥ��
values.clear();
values.put(
ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID,
groupID);
context.getContentResolver().update(ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + " =?",
new String[] { contactID, GroupMembership.CONTENT_ITEM_TYPE });
}
示例5: getContactsByGroupId
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
/**
* ��ȡij����������ϵ����Ϣ
*
* @param personId
* @param context
* @return �÷����µ�������ϵ��
*/
public ArrayList<SortEntry> getContactsByGroupId(int groupId) {
Uri uri = ContactsContract.Data.CONTENT_URI;
String[] RAW_PROJECTION = new String[] { ContactsContract.Data.RAW_CONTACT_ID, };
String RAW_CONTACTS_WHERE = ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID
+ " =? and "
+ ContactsContract.Data.MIMETYPE
+ " = '"
+ ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE
+ "'";
Cursor cursor = context.getContentResolver().query(uri, RAW_PROJECTION,
RAW_CONTACTS_WHERE, new String[] { groupId + "" }, "data1 asc");
ArrayList<SortEntry> list = new ArrayList<SortEntry>();
while (cursor.moveToNext()) {
// RAW_CONTACTS_ID
int raw_contact_id = cursor.getInt(cursor
.getColumnIndex("raw_contact_id"));
SortEntry entry = new SortEntry();
entry.mID = String.valueOf(raw_contact_id);
entry = getContactByID(raw_contact_id, entry);
list.add(entry);
entry = null;
}
cursor.close();
return list;
}
示例6: getCategoriesValues
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
private void getCategoriesValues(final JSONArray categories, List<ContentValues> newContactValues) throws JSONException {
if (categories == null) {
return;
}
for (int i = 0; i < categories.length(); i++) {
String category = categories.getString(i);
if ("my contacts".equals(category.toLowerCase()) ||
PRE_HONEYCOMB_DEFAULT_GROUP.equalsIgnoreCase(category)) {
Log.w(LOGTAG, "New contacts are implicitly added to the default group.");
continue;
}
// Find the group ID of the given category
long groupId = getGroupId(category);
// Create the group if it doesn't already exist
if (groupId == -1) {
groupId = createGroup(category);
// If the group is still -1, we failed to create the group
if (groupId == -1) {
// Only log the category name if in debug
if (DEBUG) {
Log.d(LOGTAG, "Failed to create new group for category \"" + category + "\"");
} else {
Log.w(LOGTAG, "Failed to create new group for given category.");
}
continue;
}
}
ContentValues contentValues = new ContentValues();
contentValues.put(Data.MIMETYPE, GroupMembership.CONTENT_ITEM_TYPE);
contentValues.put(GroupMembership.GROUP_ROW_ID, groupId);
newContactValues.add(contentValues);
newContactValues.add(contentValues);
}
}
示例7: addGroupMembership
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
/**
* Adds a group membership
*
* @param groupId The id of the group to assign
* @return instance of ContactOperations
*/
public ContactOperations addGroupMembership(long groupId) {
mValues.clear();
mValues.put(GroupMembership.GROUP_ROW_ID, groupId);
mValues.put(GroupMembership.MIMETYPE, GroupMembership.CONTENT_ITEM_TYPE);
addInsertOp();
return this;
}
示例8: addGroupMembership
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
public ContactOperations addGroupMembership(String groupSourceId) {
mValues.clear();
if (!TextUtils.isEmpty(groupSourceId)) {
mValues.put(GroupMembership.GROUP_SOURCE_ID, groupSourceId);
mValues.put(GroupMembership.MIMETYPE,
GroupMembership.CONTENT_ITEM_TYPE);
addInsertOp();
}
return this;
}
示例9: updateGroupMembership
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
public ContactOperations updateGroupMembership(String groupSourceId, Uri uri) {
mValues.clear();
if (TextUtils.isEmpty(groupSourceId)) {
mValues.putNull(GroupMembership.GROUP_ROW_ID);
} else {
mValues.put(GroupMembership.GROUP_SOURCE_ID, groupSourceId);
}
mValues.put(GroupMembership.MIMETYPE, GroupMembership.CONTENT_ITEM_TYPE);
addUpdateOp(uri);
return this;
}
示例10: updataCotact
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
/**
* ������ϵ��
*
* @param rawContactId
* ��ϵ��id
*/
public void updataCotact(long rawContactId, SortEntry contact,
int old_groupID) {
ContentValues values = new ContentValues();
// ��������
values.put(StructuredName.GIVEN_NAME, contact.mName);
context.getContentResolver().update(
ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(rawContactId),
StructuredName.CONTENT_ITEM_TYPE });
// ���µ绰
if (contact.mNum != "") {
values.clear();
String[] numbers = Tools.getPhoneNumber(contact.mNum);
for (int i = 0; i < numbers.length; i++) {
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
values.put(Phone.NUMBER, numbers[i]);
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
// context.getContentResolver().insert(
// ContactsContract.Data.CONTENT_URI, values);
context.getContentResolver().update(ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID+"=? and "+Data.MIMETYPE+"=?",
new String[]{String.valueOf(rawContactId),Phone.CONTENT_ITEM_TYPE});
}
}
// ����ͷ��
values.clear();
if (contact.contactPhoto != null) {
values.put(ContactsContract.CommonDataKinds.Photo.PHOTO,
ImageConvert.bitmapToByte(contact.contactPhoto));
context.getContentResolver().update(
ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + " =?",
new String[] { String.valueOf(rawContactId),
Photo.CONTENT_ITEM_TYPE });
}
// ����Ⱥ��
if (contact.groupId != 0) {
values.clear();
values.put(
ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID,
contact.groupId);
context.getContentResolver().update(
ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + " =?",
new String[] { String.valueOf(rawContactId),
GroupMembership.CONTENT_ITEM_TYPE });
} else {
new GroupDAO(context).deleteMemberFromGroup(
Integer.parseInt(contact.mID), old_groupID);
}
}
示例11: updataCotactNoPhoto
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
/**
* ������ϵ�� ��ʼû��ͷ�����ϵ��
*
* @param rawContactId
* ��ϵ��id
*/
public void updataCotactNoPhoto(long rawContactId, SortEntry contact,
int old_groupID) {
ContentValues values = new ContentValues();
// ��������
values.put(StructuredName.GIVEN_NAME, contact.mName);
context.getContentResolver().update(
ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(rawContactId),
StructuredName.CONTENT_ITEM_TYPE });
// ���µ绰
if (contact.mNum != "") {
values.clear();
String[] numbers = Tools.getPhoneNumber(contact.mNum);
for (int i = 0; i < numbers.length; i++) {
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
values.put(Phone.NUMBER, numbers[i]);
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
context.getContentResolver().update(ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID+"=? and "+Data.MIMETYPE+"=?",
new String[]{String.valueOf(rawContactId),Phone.CONTENT_ITEM_TYPE});
}
}
// ���ͷ��
if (contact.contactPhoto != null) {
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Photo.CONTENT_ITEM_TYPE);
values.put(Photo.PHOTO,
ImageConvert.bitmapToByte(contact.contactPhoto));
context.getContentResolver().insert(
ContactsContract.Data.CONTENT_URI, values);
}
// ����Ⱥ��
if (contact.groupId != 0) {
values.clear();
values.put(
ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID,
contact.groupId);
context.getContentResolver().update(
ContactsContract.Data.CONTENT_URI,
values,
Data.RAW_CONTACT_ID + "=? and " + Data.MIMETYPE + " =?",
new String[] { String.valueOf(rawContactId),
GroupMembership.CONTENT_ITEM_TYPE });
} else {
new GroupDAO(context).deleteMemberFromGroup(
Integer.parseInt(contact.mID), old_groupID);
}
}
示例12: getContactValues
import android.provider.ContactsContract.CommonDataKinds.GroupMembership; //导入依赖的package包/类
private List<ContentValues> getContactValues(final JSONObject contactProperties) throws JSONException {
List<ContentValues> contactValues = new ArrayList<ContentValues>();
// Add the contact to the default group so it is shown in other apps
// like the Contacts or People app
ContentValues defaultGroupValues = new ContentValues();
defaultGroupValues.put(Data.MIMETYPE, GroupMembership.CONTENT_ITEM_TYPE);
defaultGroupValues.put(GroupMembership.GROUP_ROW_ID, mGroupId);
contactValues.add(defaultGroupValues);
// Create all the values that will be inserted into the new contact
getNameValues(contactProperties.optJSONArray("name"),
contactProperties.optJSONArray("givenName"),
contactProperties.optJSONArray("familyName"),
contactProperties.optJSONArray("honorificPrefix"),
contactProperties.optJSONArray("honorificSuffix"),
contactValues);
getGenericValues(MIMETYPE_ADDITIONAL_NAME, CUSTOM_DATA_COLUMN,
contactProperties.optJSONArray("additionalName"), contactValues);
getNicknamesValues(contactProperties.optJSONArray("nickname"), contactValues);
getAddressesValues(contactProperties.optJSONArray("adr"), contactValues);
getPhonesValues(contactProperties.optJSONArray("tel"), contactValues);
getEmailsValues(contactProperties.optJSONArray("email"), contactValues);
//getPhotosValues(contactProperties.optJSONArray("photo"), contactValues);
getGenericValues(Organization.CONTENT_ITEM_TYPE, Organization.COMPANY,
contactProperties.optJSONArray("org"), contactValues);
getGenericValues(Organization.CONTENT_ITEM_TYPE, Organization.TITLE,
contactProperties.optJSONArray("jobTitle"), contactValues);
getNotesValues(contactProperties.optJSONArray("note"), contactValues);
getWebsitesValues(contactProperties.optJSONArray("url"), contactValues);
getImsValues(contactProperties.optJSONArray("impp"), contactValues);
getCategoriesValues(contactProperties.optJSONArray("category"), contactValues);
getEventValues(contactProperties.optString("bday"), Event.TYPE_BIRTHDAY, contactValues);
getEventValues(contactProperties.optString("anniversary"), Event.TYPE_ANNIVERSARY, contactValues);
getCustomMimetypeValues(contactProperties.optString("sex"), MIMETYPE_SEX, contactValues);
getCustomMimetypeValues(contactProperties.optString("genderIdentity"), MIMETYPE_GENDER_IDENTITY, contactValues);
getGenericValues(MIMETYPE_KEY, CUSTOM_DATA_COLUMN, contactProperties.optJSONArray("key"),
contactValues);
return contactValues;
}