I want convert every phone number from conatct in device to E164 format. So, I used opensource below.
So I used it like here.
Phonenumber.PhoneNumber formattedNumber = null;
String formatted = null;
try {
formattedNumber = phoneUtil.parse(phoneNumber, "KR");
formatted = phoneUtil.format(formattedNumber,PhoneNumberUtil.PhoneNumberFormat.E164);
if (StringUtils.isEmpty(formatted) == false && formatted.length() > 0 && StringUtils.isEmpty(name) == false && name.length() > 0) {
listName.add(name);
listPhoneNumber.add(formatted);
}
} catch (NumberParseException e) {
continue;
}
And I read that this library is used by the Android framework since 4.0.
The Java version is optimized for running on smartphones, and is used by the Android framework since 4.0 (Ice Cream Sandwich).
I want to use this from Android SDK. So I found this. Android SDK provides this PhoneNumberUtils .
And there is a function
formatNumberToE164(String phoneNumber, String defaultCountryIso)
It's really easy to use. but API level of this function is 21.
So My question is..How can I use PhoneNumberUtils to convert phonenumber to E164 under API Level 14(ICS) ~ 21?
Thanks.!