获取不带国家/地区代码的电话号码,以比较号码 [英] Get phone number without country code for the purpose of comparing numbers

查看:196
本文介绍了获取不带国家/地区代码的电话号码,以比较号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以从来电或短信中获取电话号码.不幸的是,在使用SMS的情况下,可能会包含国家/地区代码.因此,基本上,我需要获取不带国家代码的普通电话号码,以便将其与通讯录中的现有电话号码进行比较.

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);

然后,您不必担心国家/地区代码,它将只比较颠倒顺序中的数字并查看它们是否匹配(至少足以满足callerID的目的).

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).

这篇关于获取不带国家/地区代码的电话号码,以比较号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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