使用 ContactsContract 有效添加联系人
我可以将带有 ContactsContract 的联系人添加到用户的帐户之一(这本身就是一项困难的壮举!),但我仍然无法将其添加到将显示的组中。我知道用户可以转到他们的联系选项并选中他们帐户中的“显示所有(其他)联系人”框,但这不仅对用户来说是一个他们中的许多人不知道的额外步骤,我在 HTC EVO 上尝试过,我不确定 Sense 是否可行。
因此,至少,我正在寻找相当于 addToMyContactsGroup 的 ContactsContract。在更广泛的层面上,我正在寻找有关以下内容的更多详细信息:
- 如何最好地将联系人添加到组中,具体取决于他们选择将联系人添加到的帐户。
- 如何避免为同一个人堆积多个原始联系人,以防用户多次按下我的“添加到联系人”按钮(当您编辑联系人时,所有原始联系人在 Android 中都是可见且可单独编辑的)。
- 基本上如何在不使用
Intents.Insert
的情况下尽可能方便地添加联系人
谢谢各位专家!
I'm able to add a Contact with ContactsContract to one of the user's accounts (a difficult feat in itself!), but I still haven't been able to add it to a group that will show up. I know that the user can go to their contact options and check a "Show All (Other) Contacts" box in their account, but not only is this is an extra step for the user that many of them don't know about, I tried it on an HTC EVO and I'm not sure that it's even possible with Sense.
So at minimum, I'm looking for a ContactsContract equivalent to addToMyContactsGroup. On a broader level, I'm looking for more detail on:
- How to best go about adding the contact to a group, depending on the account they choose to add the contact to.
- How to avoid stacking up multiple Raw Contacts for the same person in case the user presses my "Add to Contacts" button multiple times (all Raw Contacts are visible and separately editable in Android when you edit a contact).
- Basically how to make adding a contact as user friendly as possible without using
Intents.Insert
Thanks pros!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这些组,但这就是我用于其余部分的内容:(
请阅读底部以进行解释)
声明:
操作代码:
填充代码:
此代码基本上用多个值填充大型 ArrayList 操作以插入到联系人中数据库。
您需要确保使用 .withValueBackReference(opsLength) 以便您指向正确的原始联系人。
此代码经过测试并可在运行 2.2 的 HTC Incredible 上运行。
祝你好运!
I'm not sure about the groups, but this is what I used for the rest:
(READ TO BOTTOM FOR EXPLANATION)
Declarations:
Action code:
Filler code:
This code basically fills a large ArrayList ops with several values to insert into the contacts database.
You need to make sure you use the .withValueBackReference(opsLength) so you are pointing BACK at the correct raw contact.
This code is tested and works on an HTC Incredible running 2.2.
Good luck!