gpt4 book ai didi

android - 访问 Android 联系人组名称

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:57:57 24 4
gpt4 key购买 nike

你能告诉我如何以编程方式获取联系人组吗存储在我们的安卓手机中?

最佳答案

final String[] GROUP_PROJECTION = new String[] {
ContactsContract.Groups._ID, ContactsContract.Groups.TITLE };
cursor = getContentResolver().query(
ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null,
null, ContactsContract.Groups.TITLE);

GlobalConfig.groupList.clear();
Group g = new Group();
g.GroupIdList += "0";
g.setGroupTitle("ALL");
GlobalConfig.groupList.add(g);
while (cursor.moveToNext()) {

String id = cursor.getString(cursor
.getColumnIndex(ContactsContract.Groups._ID));

String gTitle = (cursor.getString(cursor
.getColumnIndex(ContactsContract.Groups.TITLE)));

if (gTitle.contains("Group:")) {
gTitle = gTitle.substring(gTitle.indexOf("Group:") + 6).trim();

}
if (gTitle.contains("Favorite_")) {
gTitle = "Favorites";
}
if (gTitle.contains("Starred in Android")
|| gTitle.contains("My Contacts")) {
continue;
}

Group gObj = new Group();

int pos = GlobalConfig.GroupContainsTitle(gTitle);
if (pos != -1) {
gObj = GlobalConfig.groupList.get(pos);
gObj.GroupIdList += "," + id;
GlobalConfig.groupList.set(pos, gObj);

} else {
gObj.GroupIdList += id;
gObj.setGroupTitle(gTitle);
GlobalConfig.groupList.add(gObj);

}

// Log.d("GrpId Title", gObj.getGroupIdList() +
// gObj.getGroupTitle());
}

关于android - 访问 Android 联系人组名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4334649/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com