public final class PhoneNumberUtils extends Object
| Constructor and Description |
|---|
PhoneNumberUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
format(String phoneNumber,
CountryInfo countryInfo)
This method works as follow: When the android version is LOLLIPOP or greater, the
reliable {
PhoneNumberUtils.formatNumberToE164(java.lang.String, java.lang.String)} is used to
format. For lower versions, we construct a value with the input phone number
stripped of non numeric characters and prefix it with a "+" and country code |
static String |
formatUsingCurrentCountry(String phoneNumber,
Context context)
This method uses the country returned by
getCurrentCountryInfo(Context) to format
the phone number. |
static Integer |
getCountryCode(String countryIso) |
static List<String> |
getCountryIsosFromCountryCode(String countryCode) |
static CountryInfo |
getCurrentCountryInfo(Context context) |
static Map<String,Integer> |
getImmutableCountryIsoMap() |
static PhoneNumber |
getPhoneNumber(String providedPhoneNumber)
This method should not be called on UI thread.
|
static PhoneNumber |
getPhoneNumber(String providedCountryIso,
String providedNationalNumber) |
static boolean |
isValid(String number) |
static boolean |
isValidIso(String iso) |
public static String format(@NonNull String phoneNumber, @NonNull CountryInfo countryInfo)
PhoneNumberUtils.formatNumberToE164(java.lang.String, java.lang.String)} is used to
format.phoneNumber - that may or may not itself have country codecountryInfo - must have locale with ISO 3166 2-letter code for country@Nullable public static String formatUsingCurrentCountry(@NonNull String phoneNumber, Context context)
getCurrentCountryInfo(Context) to format
the phone number. Internally invokes format(String, CountryInfo)phoneNumber - that may or may not itself have country code@NonNull public static CountryInfo getCurrentCountryInfo(@NonNull Context context)
public static PhoneNumber getPhoneNumber(@NonNull String providedPhoneNumber)
providedPhoneNumber - works best when formatted as e164public static boolean isValid(@NonNull
String number)
public static boolean isValidIso(@Nullable
String iso)
public static PhoneNumber getPhoneNumber(@NonNull String providedCountryIso, @NonNull String providedNationalNumber)
getPhoneNumber(String)