Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get phone number without country code for the purpose of comparing numbers

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.

like image 936
Alin Avatar asked Jul 25 '11 08:07

Alin


People also ask

How do I add a country code to a phone number automatically?

Back to New Call; click Dialing Options; check Automatically add country/region code to local phone numbers.)

How do you add a country code without?

The plus sign before the country code means "add the exit code" of the country you are dialing from. So, using the example above, if you were dialing from the US you would replace the plus sign with 011, while, if dialing from one of the numerous countries using exit code 00, you would instead have 00 44 700 000 0000.

Why country code is important?

Country codes are short alphabetic or numeric geographical codes (geocodes) developed to represent countries and dependent areas, for use in data processing and communications.


1 Answers

If you want to compare phone numbers you can always use the

PhoneNumberUtils.compare(number1, number2);

or

PhoneNumberUtils.compare(context, number1, number2);

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

like image 51
Tomas Avatar answered Nov 12 '22 17:11

Tomas