如何获得联系人组到联系人管理器示例应用程序? (Android版) [英] How to get Contact Groups into Contact Manager Sample App? (Android)
问题描述
我正在从Android SDK中的联系人管理器示例应用程序。当我的联系人添加到我的Gmail帐户,它被添加作为一个无形的接触。我假定这是因为我没有告诉它'群',应该为联系人分配。我一直在寻找周围的互联网络几天纷纷拿出空手而归。
I am running the Contact Manager sample app from the Android SDK. When I add a contact to my Gmail account, it gets added as an 'invisible contact'. I am assuming this is because I am not telling the contact which 'group' it should be assigned to. I have been looking around the internets for a few days and have come up empty handed.
我真正想要做的是将联系人添加到我选择,并有一个联络小组选定的Gmail帐户内的相关联系人的联系人账户,所以该联系人的信息将显示在用户的联系人。
What I really want to do is add the contact to the Contact Account that I select and have the contact associated with a Contact Group within the selected Gmail Account, so the contact's info will be displayed in the user's contacts.
推荐答案
您针对哪个版本的Android?你当然知道该联系人API在2.X从根本上改变...
What version of Android are you targeting? You are of course aware that the Contacts API changed radically in 2.x...
我打了无形的联系这一具体问题,但只能在1.x的我找到了解决办法是添加到内置的我的联系人组:
I hit this exact problem of invisible contacts, but only on 1.x. I found the solution was to add to the built-in "My Contacts" group :
// Add to the My Contacts group
ContentValues values = new ContentValues();
values.put(GroupMembership.PERSON_ID, contact.mAndroidId);
values.put(GroupMembership.GROUP_ID, 1); // 1 is always the ID of the built-in "My Contacts" group
activity.getContentResolver().insert(GroupMembership.CONTENT_URI,values);
如果您要添加到特定的用户定义的组,而不是我的联系人,您将需要的捕渔权GROUP_ID出的 Contacts.Groups
表。
If you want to add to a specific user-defined group rather than My Contacts you will need to fish the right GROUP_ID out of the Contacts.Groups
table.
这篇关于如何获得联系人组到联系人管理器示例应用程序? (Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!