安卓:检索电话号码,联系人姓名 [英] Android: Retrieve contact name from phone number

查看:142
本文介绍了安卓:检索电话号码,联系人姓名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检索与进入的电话号码相关联的联系人的姓名。正如我处理的broascastreceiver来电号码具有来电主叫方的名称的String将帮助我的项目很大。

I would like to retrieve the name of a contact associated with an incoming telephone number. As I process the incoming number in the broascastreceiver having a String with the name of the incoming caller would help my project greatly.

我认为这涉及到一个查询中使用的SQL WHERE子句作为过滤器,但我需要的联系人进行排序?一个例子或暗示会有很大的帮助。

I would think this involves a query using the sql WHERE clause as a filter, but do I need to sort the contacts? An example or hint would be of great assistance.

推荐答案

对于您需要使用优化PhoneLookup提供商所描述的<一个href="http://developer.android.com/intl/de/reference/android/provider/ContactsContract.PhoneLookup.html">here

For that you need to use the optimized PhoneLookup provider as described here

Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
 resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME} .....)

这篇关于安卓:检索电话号码,联系人姓名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆