How can i delete or detect the country codes of contact numbers efficiently ?
+213231756 will be 231756 (+231 is the country code of Algeria)
+880171876809 will be 0171876809(+88 is the country code of BD)
Say for example: i create a string.xml file like
<string-array name="CountryCodes" >
<item>93,AF</item>
<item>355,AL</item>
<item>213,DZ</item>
And there are almost 190+ country codes in xml . and check every contact number with the string array isn't time efficient.
Is there any efficient solution to detect the country code of a list of phone number.
You can use "libphonenumber.jar" for this. http://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/7.3.1/
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
// phone must begin with '+'
PhoneNumber numberProto = phoneUtil.parse(phone, "");
int countryCode = numberProto.getCountryCode();
} catch (NumberParseException e) {
System.err.println("NumberParseException was thrown: " + e.toString());
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments