当前位置: 首页>>代码示例>>Java>>正文


Java Groups类代码示例

本文整理汇总了Java中android.provider.ContactsContract.Groups的典型用法代码示例。如果您正苦于以下问题:Java Groups类的具体用法?Java Groups怎么用?Java Groups使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Groups类属于android.provider.ContactsContract包,在下文中一共展示了Groups类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGroupId

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
private long getGroupId(String groupName) {
    long groupId = -1;
    Cursor cursor = getGroups(Groups.TITLE + " = '" + groupName + "'");

    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
        String groupAccountName = cursor.getString(GROUP_ACCOUNT_NAME);
        String groupAccountType = cursor.getString(GROUP_ACCOUNT_TYPE);

        // Check if the account name and type for the group match the account name and type of
        // the account we're working with or the default "Phone" account if no account was found
        if (groupAccountName.equals(mAccountName) && groupAccountType.equals(mAccountType) ||
            (mAccountName == null && "Phone".equals(groupAccountType))) {
            if (groupName.equals(cursor.getString(GROUP_TITLE))) {
                groupId = cursor.getLong(GROUP_ID);
                break;
            }
        }
    }
    cursor.close();

    return groupId;
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:24,代码来源:ContactService.java

示例2: getGroups

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
private Cursor getGroups(String selectArg) {
    String[] columns = new String[] {
        Groups.ACCOUNT_NAME,
        Groups.ACCOUNT_TYPE,
        Groups._ID,
        Groups.TITLE,
        (Versions.feature11Plus ? Groups.AUTO_ADD : Groups._ID)
    };

    if (selectArg != null) {
        selectArg = "AND " + selectArg;
    } else {
        selectArg = "";
    }

    return mContentResolver.query(Groups.CONTENT_URI, columns,
                                  Groups.ACCOUNT_TYPE + " NOT NULL AND " +
                                  Groups.ACCOUNT_NAME + " NOT NULL " + selectArg, null, null);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:20,代码来源:ContactService.java

示例3: createGroup

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
private long createGroup(String groupName) {
    if (DEBUG) {
        Log.d(LOGTAG, "Creating group: " + groupName);
    }

    ArrayList<ContentProviderOperation> newGroupOptions = new ArrayList<ContentProviderOperation>();

    // Create the group under the account we're using
    // If no account is selected, use a default account name/type for the group
    newGroupOptions.add(ContentProviderOperation.newInsert(Groups.CONTENT_URI)
                            .withValue(Groups.ACCOUNT_NAME, (mAccountName == null ? "Phone" : mAccountName))
                            .withValue(Groups.ACCOUNT_TYPE, (mAccountType == null ? "Phone" : mAccountType))
                            .withValue(Groups.TITLE, groupName)
                            .withValue(Groups.GROUP_VISIBLE, true)
                            .build());

    applyBatch(newGroupOptions);

    // Return the ID of the newly created group
    return getGroupId(groupName);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:22,代码来源:ContactService.java

示例4: GroupOperations

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
public GroupOperations(String sourceId, String accountName, String title,
		String notes, boolean isSyncOperation, BatchOperation batchOperation) {
	this(isSyncOperation, batchOperation);
	mValues.put(Groups.ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
	mValues.put(Groups.ACCOUNT_NAME, accountName);

	if (!TextUtils.isEmpty(title)) {
		mValues.put(Groups.TITLE, title);
	}

	if (!TextUtils.isEmpty(notes)) {
		mValues.put(Groups.NOTES, notes);
	}

	if (!TextUtils.isEmpty(sourceId)) {
		mValues.put(Groups.SOURCE_ID, sourceId);
	}

	ContentProviderOperation.Builder builder = newInsertCpo(
			Groups.CONTENT_URI, mIsSyncOperation, true).withValues(mValues);
	mBatchOperation.add(builder.build());
}
 
开发者ID:mgrieder,项目名称:ntsync-android,代码行数:23,代码来源:GroupOperations.java

示例5: getGroupSourceId

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
private static String getGroupSourceId(ContentResolver resolver,
		long groupId) {
	String sourceGroupId = null;
	final Cursor cursor = resolver.query(Groups.CONTENT_URI,
			new String[] { Groups.SOURCE_ID, }, Groups._ID + "=?",
			new String[] { String.valueOf(groupId) }, null);
	if (cursor != null) {
		try {
			if (cursor.moveToFirst()) {
				sourceGroupId = cursor.getString(0);
			}
		} finally {
			cursor.close();
		}
	}
	return sourceGroupId;
}
 
开发者ID:mgrieder,项目名称:ntsync-android,代码行数:18,代码来源:ContactManager.java

示例6: getGroups

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
public Map<Integer, Group> getGroups(Context context) {
  final Map<Integer, Group> map = new LinkedHashMap<Integer, Group>();

  map.put(EVERYBODY_ID, new Group(EVERYBODY_ID, context.getString(R.string.everybody), 0));

  final Cursor c = context.getContentResolver().query(
            Groups.CONTENT_SUMMARY_URI,
            new String[] { Groups._ID, Groups.TITLE, Groups.SUMMARY_COUNT },
            null,
            null,
            Groups.TITLE + " ASC");

  while (c != null && c.moveToNext()) {
    map.put(c.getInt(0), new Group(c.getInt(0), c.getString(1), c.getInt(2)));
  }

  if (c != null) c.close();
  return map;
}
 
开发者ID:zhenlonghe,项目名称:fnzy,代码行数:20,代码来源:ContactAccessorPost20.java

示例7: getGroups

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
@Override
public Cursor getGroups(Context context) {
    Uri searchUri = Groups.CONTENT_URI;
    String[] projection = new String[] {
            Groups._ID,
            Groups.TITLE /* No need of as title, since already title */
    };
    
    return context.getContentResolver().query(searchUri, projection, null, null,
            Groups.TITLE + " ASC");
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:12,代码来源:ContactsUtils5.java

示例8: getGroups

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
/**
 * ��ȡ������ϵ�˷���
 * 
 * @param context
 *            ������
 * @return
 */
public ArrayList<GroupBean> getGroups() {
	Cursor cursor = context.getContentResolver().query(Groups.CONTENT_URI,
			null, null, null, null);
	ArrayList<GroupBean> list = new ArrayList<GroupBean>();

	while (cursor.moveToNext()) {
		// �õ�״̬--�Ƿ�ɾ��
		int isDeleted = cursor
				.getInt(cursor.getColumnIndex(Groups.DELETED));
		if (isDeleted == 0) {
			GroupBean gb = new GroupBean();
			// �������
			String name = cursor.getString(cursor
					.getColumnIndex(Groups.TITLE));
			gb.setName(name);
			// �����id
			int groupId = cursor.getInt(cursor.getColumnIndex(Groups._ID));
			gb.setId(groupId);
			int count = new ContactDAO(context).getContactsByGroupId(
					groupId).size();
			gb.setCount(count);
			list.add(gb);
		}
	}
	cursor.close();
	return list;
}
 
开发者ID:nighthary,项目名称:phoneContact,代码行数:35,代码来源:GroupDAO.java

示例9: updataGroup

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
/**
 * �޸�Ⱥ����
 * 
 * @param rawContactId
 */
public void updataGroup(int groupId, String groupName) {
	System.out.println("update group...");
	ContentValues values = new ContentValues();
	values.put(Groups.TITLE, groupName);
	String where = ContactsContract.Groups._ID + "=? ";
	String[] selectionArgs = new String[] { String.valueOf(groupId) };
	context.getContentResolver().update(Groups.CONTENT_URI, values, where,
			selectionArgs);
}
 
开发者ID:nighthary,项目名称:phoneContact,代码行数:15,代码来源:GroupDAO.java

示例10: getGroupNameByGroupId

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
public String getGroupNameByGroupId(long groupId) {
	String groupName = "";
	String[] PROJECTION = new String[] { Groups.TITLE };
	String SELECTION = Groups._ID + "=?";
	Cursor cursor = context.getContentResolver().query(Groups.CONTENT_URI,
			PROJECTION, SELECTION, new String[] { groupId + "" }, null);
	while (cursor.moveToNext()) {
		groupName = cursor.getString(cursor.getColumnIndex(Groups.TITLE));
	}
	cursor.close();
	return groupName;
}
 
开发者ID:nighthary,项目名称:phoneContact,代码行数:13,代码来源:GroupDAO.java

示例11: getIdByGroupName

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
public int getIdByGroupName(String groupName) {
	int groupId = 0;
	String[] PROJECTION = new String[] { Groups._ID };
	String SELECTION = Groups.TITLE + "=?";
	Cursor cursor = context.getContentResolver().query(Groups.CONTENT_URI,
			PROJECTION, SELECTION, new String[] { groupName + "" }, null);
	while (cursor.moveToNext()) {
		groupId = cursor.getInt(cursor.getColumnIndex(Groups._ID));
	}
	cursor.close();
	return groupId;
}
 
开发者ID:nighthary,项目名称:phoneContact,代码行数:13,代码来源:GroupDAO.java

示例12: GroupListLoader

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
public GroupListLoader(Context context) {
    super(context, GROUP_LIST_URI, COLUMNS, Groups.ACCOUNT_TYPE + " NOT NULL AND "
                    + Groups.ACCOUNT_NAME + " NOT NULL AND " + Groups.AUTO_ADD + "=0 AND " +
                    Groups.FAVORITES + "=0 AND " + Groups.DELETED + "=0", null,
            Groups.ACCOUNT_TYPE + ", " + Groups.ACCOUNT_NAME + ", " + Groups.DATA_SET + ", " +
                    Groups.TITLE + " COLLATE LOCALIZED ASC");
}
 
开发者ID:omarkadry,项目名称:text-merge,代码行数:8,代码来源:GroupListLoader.java

示例13: getGroupName

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
private String getGroupName(long groupId) {
    Cursor cursor = getGroups(Groups._ID + " = " + groupId);

    if (cursor.getCount() == 0) {
        cursor.close();
        return null;
    }

    cursor.moveToPosition(0);
    String groupName = cursor.getString(cursor.getColumnIndex(Groups.TITLE));
    cursor.close();

    return groupName;
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:15,代码来源:ContactService.java

示例14: AddressbookManagerAndroid

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
public AddressbookManagerAndroid(Context context,
		ContentResolver contentResolver) {
	this.cr = contentResolver;
	// this.context = context;

	am = AccountManager.get(context);

	panboxAccount = new Account(accountName, accountType);
	am.addAccountExplicitly(panboxAccount, null, null);

	ContentProviderClient client = contentResolver
			.acquireContentProviderClient(ContactsContract.AUTHORITY_URI);
	ContentValues values = new ContentValues();
	values.put(ContactsContract.Groups.ACCOUNT_NAME, accountName);
	values.put(Groups.ACCOUNT_TYPE, accountType);
	values.put(Settings.UNGROUPED_VISIBLE, true);
	values.put(Settings.SHOULD_SYNC, false);
	try {
		client.insert(
				Settings.CONTENT_URI
						.buildUpon()
						.appendQueryParameter(
								ContactsContract.CALLER_IS_SYNCADAPTER,
								"true").build(), values);
	} catch (RemoteException e) {
		e.printStackTrace();
	}

}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:30,代码来源:AddressbookManagerAndroid.java

示例15: ensureXWikiGroupExists

import android.provider.ContactsContract.Groups; //导入依赖的package包/类
public static long ensureXWikiGroupExists(Context context, String accountName) {
    final ContentResolver resolver = context.getContentResolver();

    // Lookup the group
    long groupId = 0;
    final Cursor cursor = resolver.query(Groups.CONTENT_URI, new String[]{Groups._ID},
            Groups.ACCOUNT_NAME + "=? AND " + Groups.ACCOUNT_TYPE + "=? AND " +
                    Groups.TITLE + "=?",
            new String[]{accountName, Constants.ACCOUNT_TYPE, XWIKI_GROUP_NAME}, null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                groupId = cursor.getLong(0);
            }
        } finally {
            cursor.close();
        }
    }

    if (groupId == 0) {
        // the group doesn't exist yet, so create it
        final ContentValues contentValues = new ContentValues();
        contentValues.put(Groups.ACCOUNT_NAME, accountName);
        contentValues.put(Groups.ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
        contentValues.put(Groups.TITLE, XWIKI_GROUP_NAME);
        contentValues.put(Groups.GROUP_IS_READ_ONLY, true);

        final Uri newGroupUri = resolver.insert(Groups.CONTENT_URI, contentValues);
        groupId = ContentUris.parseId(newGroupUri);
    }
    return groupId;
}
 
开发者ID:xwiki-contrib,项目名称:android-authenticator,代码行数:33,代码来源:ContactManager.java


注:本文中的android.provider.ContactsContract.Groups类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。