Package com.firebase.ui.auth.util.data
Class PhoneNumberUtils
- java.lang.Object
-
- com.firebase.ui.auth.util.data.PhoneNumberUtils
-
public final class PhoneNumberUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description PhoneNumberUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringformat(java.lang.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 codestatic java.lang.StringformatUsingCurrentCountry(java.lang.String phoneNumber, android.content.Context context)This method uses the country returned bygetCurrentCountryInfo(Context)to format the phone number.static java.lang.IntegergetCountryCode(java.lang.String countryIso)static java.util.List<java.lang.String>getCountryIsosFromCountryCode(java.lang.String countryCode)static CountryInfogetCurrentCountryInfo(android.content.Context context)static java.util.Map<java.lang.String,java.lang.Integer>getImmutableCountryIsoMap()static PhoneNumbergetPhoneNumber(java.lang.String providedPhoneNumber)This method should not be called on UI thread.static PhoneNumbergetPhoneNumber(java.lang.String providedCountryIso, java.lang.String providedNationalNumber)static booleanisValid(java.lang.String number)static booleanisValidIso(java.lang.String iso)
-
-
-
Method Detail
-
format
public static java.lang.String format(@NonNull java.lang.String phoneNumber, @NonNull 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
- Parameters:
phoneNumber- that may or may not itself have country codecountryInfo- must have locale with ISO 3166 2-letter code for country
- When the android version is LOLLIPOP or greater, the
reliable {
-
formatUsingCurrentCountry
@Nullable public static java.lang.String formatUsingCurrentCountry(@NonNull java.lang.String phoneNumber, android.content.Context context)This method uses the country returned bygetCurrentCountryInfo(Context)to format the phone number. Internally invokesformat(String, CountryInfo)- Parameters:
phoneNumber- that may or may not itself have country code
-
getCurrentCountryInfo
@NonNull public static CountryInfo getCurrentCountryInfo(@NonNull android.content.Context context)
-
getPhoneNumber
public static PhoneNumber getPhoneNumber(@NonNull java.lang.String providedPhoneNumber)
This method should not be called on UI thread. Potentially creates a country code by iso map which can take long in some devices- Parameters:
providedPhoneNumber- works best when formatted as e164- Returns:
- an instance of the PhoneNumber using the SIM information
-
isValid
public static boolean isValid(@NonNull java.lang.String number)
-
isValidIso
public static boolean isValidIso(@Nullable java.lang.String iso)
-
getPhoneNumber
public static PhoneNumber getPhoneNumber(@NonNull java.lang.String providedCountryIso, @NonNull java.lang.String providedNationalNumber)
- See Also:
getPhoneNumber(String)
-
getCountryCode
@Nullable public static java.lang.Integer getCountryCode(java.lang.String countryIso)
-
getImmutableCountryIsoMap
public static java.util.Map<java.lang.String,java.lang.Integer> getImmutableCountryIsoMap()
-
getCountryIsosFromCountryCode
@Nullable public static java.util.List<java.lang.String> getCountryIsosFromCountryCode(java.lang.String countryCode)
-
-