Android:使用查找键管理联系人
跟进这个问题:
(见下文)
我有同样的问题。但是,它在 Android 2.1 Update 1 上显示,但在 Android 2.2 上没问题。
在 Android 2.1 中,查找键似乎会随着联系人姓名的变化而变化,但在 Android 2.2 中不会发生变化。
还有其他人经历过吗?对于 Android 2.1 有什么建议的解决方法吗?
谢谢
chromate 的原始问题
大家好,
我目前正在编写一个允许保存草稿的应用程序(使用 android 版本 >= 2.0)。每个草稿都通过 ContactsContract.Contacts.LOOKUP_KEY 连接到联系人。我的问题是,如果我更改联系人姓名,查找键也会更改。是这样的吗?
那么我为什么需要查找键呢?我认为查找键永远不会改变,但现在无论如何它都会改变。我对这种行为感到困惑......
有人可以向我解释如何永久链接到联系人吗?我应该使用 ID 而不是查找键吗?
提前致谢。
Following up on this question:
Android: Manage contacts with lookup key
(see below)
I have the same problem. However, it shows with Android 2.1 Update 1, But is OK with Android 2.2.
It seems that the lookup key changes with contact's name change with Android 2.1, but does not change with Android 2.2.
Did anybody else experience this? Any suggested workaround for Android 2.1?
Thanks
Original question by chromate
Hi everybody,
I'm currently writing a application that allows to save drafts (using android version >= 2.0). Each draft is connected to a contact via the ContactsContract.Contacts.LOOKUP_KEY. My problem is that if I change the name of my contact the lookup key changes also. Is that the way this works?
So for what do I need a lookup key? I thought that the lookup key does never change and now it changes anyway. I'm confused about that behavior ...
Can someone explain to me how to link permanently to a contact? Should I use IDs instead of the lookup key?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用联系人 ID 来代替。查找键不稳定。所以我们不要查找密钥。而 contact id 的好处是它不会太多。因此,请使用联系人 ID。祝你好运
You can use contact ids instead of that. Look up key is not stable. So do not us look up key. And the benefit of contact id is it won't very. So use contact id. good luck
为什么不使用原始联系人 ID 来查找联系人 ID 或查找密钥?
这是2.1中的错误。
查找键基于未同步联系人的联系人姓名。
http://comments.gmane.org/gmane.comp.handhelds.android .devel/130677
why don't you find contact id or lookup key via using raw contact id?
this is bug in 2.1.
Lookup key was based on the contact name for unsynced contacts.
http://comments.gmane.org/gmane.comp.handhelds.android.devel/130677
即使查找键发生变化,它仍然会指向同一个联系人。
来自: https://developer.android.com/guide/topics/providers/ contacts-provider
ContactsContract.Contacts 表还具有 LOOKUP_KEY 列,该列是指向联系人行的“永久”链接。由于联系人提供程序会自动维护联系人,因此它可能会更改联系人行的 _ID 值以响应聚合或同步。即使发生这种情况,内容 URI CONTENT_LOOKUP_URI 与联系人的 LOOKUP_KEY 组合仍将指向联系人行,因此您可以使用 LOOKUP_KEY 来维护指向“最喜欢的”联系人的链接,等等。该列有其自己的格式,与 _ID 列的格式无关。
even a lookup key is changed, it will still point to same contact.
from: https://developer.android.com/guide/topics/providers/contacts-provider
The ContactsContract.Contacts table also has the column LOOKUP_KEY that is a "permanent" link to the contact row. Because the Contacts Provider maintains contacts automatically, it may change a contact row's _ID value in response to an aggregation or sync. Even If this happens, the content URI CONTENT_LOOKUP_URI combined with contact's LOOKUP_KEY will still point to the contact row, so you can use LOOKUP_KEY to maintain links to "favorite" contacts, and so forth. This column has its own format that is unrelated to the format of the _ID column.