按(标准化)电话号码查询联系人
我真的很惊讶我在任何地方都找不到答案。所以问题就在这里。
ContentResolver resolver = getContentResolver();
String[] columns = new String[]{Phone.CONTACT_ID, Phone.DISPLAY_NAME, Phone.NUMBER };
String where = Phone.NUMBER+"=?";
String[] params = new String[] {"777 777 7777"};
Cursor cursor = resolver.query(Phone.CONTENT_URI, columns, where, params, null);
while (cursor.moveToNext()) { /* So on....*/
当 params 中的电话号码格式为“777 777 7777”时,我没有得到任何记录。当它是“777-777-7777”时,它会获取记录。更糟糕的是 TelephonyManager.EXTRA_INCOMING_NUMBER 给我的号码为“7777777777”。如何查询这个电话号码?文档说 Phone.NUMBER 是用户输入它的方式。好吧,这对我没有任何好处!
I'm really surprised I can't find the answer anywhere. So here's the problem.
ContentResolver resolver = getContentResolver();
String[] columns = new String[]{Phone.CONTACT_ID, Phone.DISPLAY_NAME, Phone.NUMBER };
String where = Phone.NUMBER+"=?";
String[] params = new String[] {"777 777 7777"};
Cursor cursor = resolver.query(Phone.CONTENT_URI, columns, where, params, null);
while (cursor.moveToNext()) { /* So on....*/
When the phone number in params is formated as "777 777 7777" I get no records. When it is "777-777-7777" it get records. Even worse still the TelephonyManager.EXTRA_INCOMING_NUMBER gives me the number as "7777777777". How do I query for this phone number? The docs say Phone.NUMBER is how the user ENTERED it. Well, that doesn't do me any good!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
编辑(根据您的评论)
Try this :
Edited (According to Your Comment)