Android ContactsContract.Contact 缺少 API 中的常量?
我已经使用 ContactsContract api 一段时间了,我发现 ContactsContract.Contacts 的 API 页面中列出了两个“列”,它们实际上似乎不可评估。
这些值是(在列标题下): “NAME_RAW_CONTACT_ID”和“DISPLAY_NAME_PRIMARY”
通过我对 API 的阅读,这两个值似乎连接到用于构造给定联系人的显示名称的结构化名称(在数据中)。目前,直接从联系人表访问它对我来说非常有用,但据我所知,它们实际上并不在工作 API 中(我已经针对 2.1 和 2.2 进行了测试)。
Contacts 对象中不存在关联的常量,并且尝试直接访问字段(通过使用我在在线代码转储中看到的小写字符串版本)会出现 sql 错误 - 无效列,正如您所期望的那样。
有没有人在访问这些内容时运气更好?这些实际上在 API 中吗?
编辑: 我做了更多检查,下面是 API 上列出的 RawContacts 中的一些相关值,但实际上似乎并不在其中:DISPLAY_NAME_ALTERNATIVE、DISPLAY_NAME_PRIMARY、DISPLAY_NAME_SOURCE、PHONETIC_NAME、PHONETIC_NAME_STYLE、SORT_KEY_ALTERNATIVE 和 SORT_KEY_PRIMARY。
所有这些似乎都是 API 中尚未包含的功能,在发布 javadoc 时没有被错误地过滤掉。如果其他人也无法访问这些功能,则可能值得提交错误报告。
I've been using the ContactsContract api for some time now and I've come across two "columns" listed in the API page for ContactsContract.Contacts that do not appear to actually be assessable.
The values are (under the columns heading):
"NAME_RAW_CONTACT_ID" and "DISPLAY_NAME_PRIMARY"
By my reading of the API these two values would seem to connect to the Structured Name (in DATA) used to construct the display name for the given contact. Having access to this directly from the contact table would be incredibly useful to me at the moment, but as far as I can tell they are not actually in the working api (I've tested against both 2.1 and 2.2).
The associated constants do not exist in the Contacts object, and attempting to access the fields directly (by using the lower case string versions I've seen in code dumps online) turns up with an sql error -- invalid column, as you might expect.
Has anyone had any better luck with accessing these? Are these actually in the API?
Edit:
I did some more checking and here's some related values from RawContacts that are listed on the API but appear to not actually be in it: DISPLAY_NAME_ALTERNATIVE, DISPLAY_NAME_PRIMARY, DISPLAY_NAME_SOURCE, PHONETIC_NAME, PHONETIC_NAME_STYLE, SORT_KEY_ALTERNATIVE, and SORT_KEY_PRIMARY.
All of these appear to be features not yet in the API that are mistakenly not filtered out when the javadoc was released. If other folks are unable to access these features as well it might be worth filing a bug report over.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你提到的这些项目很有趣。
其中显示“自 API 级别” 没有级别提及。
我认为错误报告是适当的。
Interesting thing about these items you mention.
Where it says "since API level" no level is mentioned.
I think a bug report is in order.
我也发现了同样的事情。当我浏览本机联系人应用程序时,他们一直在使用 DISPLAY_NAME_ALTERNATIVE 。在 API 中,他们已在接口
http://developer.android.com/reference/android/provider/ContactsContract.DataColumnsWithJoins.html
我还提取了原生联系人并检查了 raw_contacts 表。在那里我能够找到“display_name_alt”作为一个选项。
所以我不知道该怎么办。我不知道专栏名称是否有帮助
I too found the same thing . When i went through the native contacts application they have been using the DISPLAY_NAME_ALTERNATIVE .In the API they have listed these in an interface
http://developer.android.com/reference/android/provider/ContactsContract.DataColumnsWithJoins.html
I also pulled the native contacts and checked the raw_contacts table. There I was able to find the "display_name_alt" as a coulmn.
So i dont know how to go about things . I dont know if the name of the column would help
我还想使用其中一些字段(版本 2.2),但 ContactsContract.DataColumnsWithJoins.DISPLAY_NAME_ALTERNATIVE 静态字符串不可见。
因此,我直接将其值用于查询“display_name_alt”,并且我拥有该字段的数据。
我还使用了一个询问所有字段的查询(将 null 放入 ManagedQuery() 函数的“String[] 投影”变量中)并检索了所有字段。
我在 sortOrder 变量中插入了一个错误,以检索错误和自动创建的 SQL。
所以 SQL 是这样的
所以你可以看到所有可用的字段。
我不知道如何从 Uri 中获取带有 SQL 字符串的 Cursor,例如 rawQuery() ...
I also wanted to use some of these fields (ver 2.2), but the ContactsContract.DataColumnsWithJoins.DISPLAY_NAME_ALTERNATIVE static string is not visible.
So I used directly its value for the query, "display_name_alt", and I had that field's data.
I used also a query asking for all fields (putting null in 'String[] projection' variable of managedQuery() function) and retrieved all fileds.
I inserted a mistake in sortOrder variable, to retrieve the error and the automatically created SQL.
So SQL was like this
So you can see all available fields.
That I don't know how, is to get a Cursor with an SQL string from a Uri, like rawQuery() ...