联系人号码的格式 [英] Formatting of number from contacts

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

问题描述

我正在为Android编写一些短信应用程序,但是我遇到了问题。我从一个模拟器向另一个模拟器发送短信。该短信具有 15555215556作为其发送的电话号码。当我将该号码保存到联系人时,它以 + 1-555-521-5556格式保存。接下来,当我的应用搜索电话簿以查找匹配的电话号码时,找不到任何电话号码,因为 15555215556与电话簿中的 + 1-555-521-5556不同。

I'm writing some sms application for android and i have a problem. I send sms from one emulator to another. That sms has "15555215556" as phone number it was sent from. When i save that number to contacts, it's saved in "+1-555-521-5556" format. Next, when my app search phone book to find matching phone number, it couldn't find any, because "15555215556" is not the same as "+1-555-521-5556" (in phone book).

有没有可以正确格式化给定电话号码的内置类?

Is there any built-in class that can properly format given phone number?

推荐答案

有电话号码实用程序类

http://developer.android.com/reference/android/telephony/PhoneNumberUtils.html

否则,您可以使用libphoneumber

otherwise you can use libphoneumber

http://code.google.com/p/ libphonenumber /

仅140 KB

这篇关于联系人号码的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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