获取电话号码而不全国code Android中 [英] Get phone number without country code in Android
问题描述
相当困难的任务。我可以从一个来话呼叫或从SMS消息获得的电话号码。不幸的是,万一短信有可能是该国code在里面。所以,基本上我需要获得普通的电话号码,没有国家code,为了将其与现有的数字比较通讯录。
Quite a frustrating task. I can obtain the phone number from an incoming call or from a sms message. unfortunately, in case of the SMS there might be the country code in it. So, basically I need to obtain the plain phone number, without country code, in order to compare it with existing numbers in Contacts.
推荐答案
如果你想比较的电话号码,你可以随时使用
If you want to compare phone numbers you can always use the
PhoneNumberUtils.compare(number1, number2);
或
PhoneNumberUtils.compare(context, number1, number2);
然后,你不必担心该国code,它只会从相反的顺序进行比较的数字,看看它们是否匹配(足够主叫号码的目的至少)。
Then you don't have to worry about the country code, it will just compare the numbers from the reversed order and see if they match (enough for callerID purposes at least).
这篇关于获取电话号码而不全国code Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!