使用“ContactsContract”从联系人检索电话号码通过身份证?

发布于 2024-10-16 21:38:56 字数 442 浏览 13 评论 0原文

我可以使用 id 代码检索联系人的显示名称,如下所示:

Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, selectedid);
Cursor cur = managedQuery(uri, null, null, null, null);
startManagingCursor(cur);
cur.moveToNext();
String mname = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

其中“selectedid”是我要检索的联系人的 id。 现在我在从该 ID 检索电话号码时遇到问题。

如果可能的话,您可以输入我必须添加的代码来从该 ID 获取电话号码吗

I'm able to retrieve the display name of contact using the id Code as follows:

Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, selectedid);
Cursor cur = managedQuery(uri, null, null, null, null);
startManagingCursor(cur);
cur.moveToNext();
String mname = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

Where the "selectedid" is my id of the contact to be retrieved.
Now i have a problem in retrieving the phone number from that id.

If possible can u type me the code which i have to add to get the phone number from that id

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

多彩岁月 2024-10-23 21:38:56

你有没有尝试过:

String number = cur.getString(cur.getColumnIndex(
    ContactsContract.CommonDataKinds.Phone.NUMBER));

Have you tried:

String number = cur.getString(cur.getColumnIndex(
    ContactsContract.CommonDataKinds.Phone.NUMBER));
稍尽春風 2024-10-23 21:38:56

我有点想通了....尝试下面的链接...

从 Android 中的 URI 检索联系电话号码< /p>

i kind of figured it out .... try the link bellow...

Retrieve Contact Phone Number From URI in Android

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文