Using LibPhoneNumber google lib in Android Using LibPhoneNumber google lib in Android android android

Using LibPhoneNumber google lib in Android


If you're using Android studio use

implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.32'

If you want to download the latest JAR file goto

http://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber


Hi Please use this function to pass phone number and country code like india 91

public static String parseContact(String contact, String countrycode) {    PhoneNumber phoneNumber = null;    PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();    String finalNumber = null;    String isoCode = phoneNumberUtil.getRegionCodeForCountryCode(Integer.parseInt(countrycode));    boolean isValid = false;    PhoneNumberType isMobile = null;    try {        phoneNumber = phoneNumberUtil.parse(contact, isoCode);        isValid = phoneNumberUtil.isValidNumber(phoneNumber);        isMobile = phoneNumberUtil.getNumberType(phoneNumber);    } catch (NumberParseException e) {        e.printStackTrace();    } catch (NullPointerException e) {        e.printStackTrace();    }    if (isValid            && (PhoneNumberType.MOBILE == isMobile || PhoneNumberType.FIXED_LINE_OR_MOBILE == isMobile)) {        finalNumber = phoneNumberUtil.format(phoneNumber,                PhoneNumberFormat.E164).substring(1);    }    return finalNumber;}


Please try using libphonenumber-2.5.1.jar from the download page:

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

The jar from the Right-Number project works because they are using libphonenumber-2.4.jar. The CANON_EQ flag was introduced in v2.5, but is now removed from 2.5.1 to be compatible with Android until it supports the flag.