PhoneNumberUtils
  public
  
  
  
  class
  PhoneNumberUtils
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.telephony.PhoneNumberUtils | 
Various utilities for dealing with phone number strings.
Summary
| Constants | |
|---|---|
| int | BCD_EXTENDED_TYPE_CALLED_PARTY
 | 
| int | BCD_EXTENDED_TYPE_EF_ADN
 | 
| int | FORMAT_JAPANJapanese formatting | 
| int | FORMAT_NANPNANP formatting | 
| int | FORMAT_UNKNOWNThe current locale is unknown, look for a country code or don't format | 
| char | PAUSE
 | 
| int | TOA_International
 | 
| int | TOA_Unknown
 | 
| char | WAIT
 | 
| char | WILD
 | 
| Public constructors | |
|---|---|
| 
      PhoneNumberUtils()
       | |
| Public methods | |
|---|---|
| 
        
        
        static
        
        
        void | 
      addTtsSpan(Spannable s, int start, int endExclusive)
      Attach a  | 
| 
        
        
        static
        
        
        boolean | 
      areSamePhoneNumber(String number1, String number2, String defaultCountryIso)
      Determines if two phone numbers are the same. | 
| 
        
        
        static
        
        
        String | 
      calledPartyBCDFragmentToString(byte[] bytes, int offset, int length, int bcdExtType)
      Like calledPartyBCDToString, but field does not start with a TOA byte. | 
| 
        
        
        static
        
        
        String | 
      calledPartyBCDFragmentToString(byte[] bytes, int offset, int length)
      
      This method was deprecated
      in API level 28.
    use  | 
| 
        
        
        static
        
        
        String | 
      calledPartyBCDToString(byte[] bytes, int offset, int length, int bcdExtType)
      3GPP TS 24.008 10.5.4.7 Called Party BCD Number See Also TS 51.011 10.5.1 "dialing number/ssc string" and TS 11.11 "10.3.1 EF adn (Abbreviated dialing numbers)" | 
| 
        
        
        static
        
        
        String | 
      calledPartyBCDToString(byte[] bytes, int offset, int length)
      
      This method was deprecated
      in API level 28.
    use  | 
| 
        
        
        static
        
        
        boolean | 
      compare(Context context, String a, String b)
      
      This method was deprecated
      in API level 31.
    use  | 
| 
        
        
        static
        
        
        boolean | 
      compare(String a, String b)
      
      This method was deprecated
      in API level 31.
    use  | 
| 
        
        
        static
        
        
        String | 
      convertKeypadLettersToDigits(String input)
      Translates any alphabetic letters (i.e. | 
| 
        
        
        static
        
        
        TtsSpan | 
      createTtsSpan(String phoneNumberString)
      Create a  | 
| 
        
        
        static
        
        
        CharSequence | 
      createTtsSpannable(CharSequence phoneNumber)
      Wrap the supplied  | 
| 
        
        
        static
        
        
        String | 
      extractNetworkPortion(String phoneNumber)
      Extracts the network address portion and canonicalizes (filters out separators.) Network address portion is everything up to DTMF control digit separators (pause or wait), but without non-dialable characters. | 
| 
        
        
        static
        
        
        String | 
      extractPostDialPortion(String phoneNumber)
      Extracts the post-dial sequence of DTMF control digits, pauses, and waits. | 
| 
        
        
        static
        
        
        void | 
      formatJapaneseNumber(Editable text)
      This method was deprecated in API level 21. Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead | 
| 
        
        
        static
        
        
        void | 
      formatNanpNumber(Editable text)
      This method was deprecated in API level 21. Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead | 
| 
        
        
        static
        
        
        String | 
      formatNumber(String phoneNumber, String phoneNumberE164, String defaultCountryIso)
      Format the phone number only if the given number hasn't been formatted. | 
| 
        
        
        static
        
        
        void | 
      formatNumber(Editable text, int defaultFormattingType)
      This method was deprecated in API level 21. Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead | 
| 
        
        
        static
        
        
        String | 
      formatNumber(String source)
      This method was deprecated in API level 21. Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead | 
| 
        
        
        static
        
        
        String | 
      formatNumber(String phoneNumber, String defaultCountryIso)
      Format a phone number. | 
| 
        
        
        static
        
        
        String | 
      formatNumberToE164(String phoneNumber, String defaultCountryIso)
      Formats the specified  | 
| 
        
        
        static
        
        
        String | 
      formatNumberToRFC3966(String phoneNumber, String defaultCountryIso)
      Formats the specified  | 
| 
        
        
        static
        
        
        int | 
      getFormatTypeForLocale(Locale locale)
      This method was deprecated in API level 21. Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead | 
| 
        
        
        static
        
        
        String | 
      getNumberFromIntent(Intent intent, Context context)
      Extracts the phone number from an Intent. | 
| 
        
        
        static
        
        
        String | 
      getStrippedReversed(String phoneNumber)
      Returns the network portion reversed. | 
| 
        
        
        static
        final
        
        boolean | 
      is12Key(char c)
      True if c is ISO-LATIN characters 0-9, *, # | 
| 
        
        
        static
        final
        
        boolean | 
      isDialable(char c)
      True if c is ISO-LATIN characters 0-9, *, # , +, WILD | 
| 
        
        
        static
        
        
        boolean | 
      isEmergencyNumber(String number)
      
      This method was deprecated
      in API level 29.
    Please use  | 
| 
        
        
        static
        
        
        boolean | 
      isGlobalPhoneNumber(String phoneNumber)
       | 
| 
        
        
        static
        
        
        boolean | 
      isISODigit(char c)
      True if c is ISO-LATIN characters 0-9 | 
| 
        
        
        static
        
        
        boolean | 
      isLocalEmergencyNumber(Context context, String number)
      
      This method was deprecated
      in API level 29.
    Please use  | 
| 
        
        
        static
        final
        
        boolean | 
      isNonSeparator(char c)
      True if c is ISO-LATIN characters 0-9, *, # , +, WILD, WAIT, PAUSE | 
| 
        
        
        static
        final
        
        boolean | 
      isReallyDialable(char c)
      True if c is ISO-LATIN characters 0-9, *, # , + (no WILD) | 
| 
        
        
        static
        final
        
        boolean | 
      isStartsPostDial(char c)
      This any anything to the right of this char is part of the post-dial string (eg this is PAUSE or WAIT) | 
| 
        
        
        static
        
        
        boolean | 
      isVoiceMailNumber(String number)
      isVoiceMailNumber: checks a given number against the voicemail number provided by the RIL and SIM card. | 
| 
        
        
        static
        
        
        boolean | 
      isWellFormedSmsAddress(String address)
      Return true iff the network portion of  | 
| 
        
        
        static
        
        
        boolean | 
      isWpsCallNumber(String number)
      Check if the number is for Wireless Priority Service call. | 
| 
        
        
        static
        
        
        byte[] | 
      networkPortionToCalledPartyBCD(String s)
      Note: calls extractNetworkPortion(), so do not use for SIM EF[ADN] style records Returns null if network portion is empty. | 
| 
        
        
        static
        
        
        byte[] | 
      networkPortionToCalledPartyBCDWithLength(String s)
      Same as  | 
| 
        
        
        static
        
        
        String | 
      normalizeNumber(String phoneNumber)
      Normalize a phone number by removing the characters other than digits. | 
| 
        
        
        static
        
        
        byte[] | 
      numberToCalledPartyBCD(String number, int bcdExtType)
      Convert a dialing number to BCD byte array | 
| 
        
        
        static
        
        
        byte[] | 
      numberToCalledPartyBCD(String number)
      
      This method was deprecated
      in API level 28.
    use  | 
| 
        
        
        static
        
        
        String | 
      replaceUnicodeDigits(String number)
      Replaces all unicode(e.g. Arabic, Persian) digits with their decimal digit equivalents. | 
| 
        
        
        static
        
        
        String | 
      stringFromStringAndTOA(String s, int TOA)
      Basically: makes sure there's a + in front of a TOA_International number Returns null if s == null | 
| 
        
        
        static
        
        
        String | 
      stripSeparators(String phoneNumber)
      Strips separators from a phone number string. | 
| 
        
        
        static
        
        
        String | 
      toCallerIDMinMatch(String phoneNumber)
      Returns the rightmost minimum matched characters in the network portion in *reversed* order This can be used to do a database lookup against the column that stores getStrippedReversed() Returns null if phoneNumber == null | 
| 
        
        
        static
        
        
        int | 
      toaFromString(String s)
      Returns the TOA for the given dial string Basically, returns TOA_International if there's a + prefix | 
| Inherited methods | |
|---|---|
Constants
BCD_EXTENDED_TYPE_CALLED_PARTY
public static final int BCD_EXTENDED_TYPE_CALLED_PARTY
Constant Value: 2 (0x00000002)
BCD_EXTENDED_TYPE_EF_ADN
public static final int BCD_EXTENDED_TYPE_EF_ADN
Constant Value: 1 (0x00000001)
FORMAT_JAPAN
public static final int FORMAT_JAPAN
Japanese formatting
Constant Value: 2 (0x00000002)
FORMAT_NANP
public static final int FORMAT_NANP
NANP formatting
Constant Value: 1 (0x00000001)
FORMAT_UNKNOWN
public static final int FORMAT_UNKNOWN
The current locale is unknown, look for a country code or don't format
Constant Value: 0 (0x00000000)
TOA_International
public static final int TOA_International
Constant Value: 145 (0x00000091)
TOA_Unknown
public static final int TOA_Unknown
Constant Value: 129 (0x00000081)
Public constructors
PhoneNumberUtils
public PhoneNumberUtils ()
Public methods
addTtsSpan
public static void addTtsSpan (Spannable s, int start, int endExclusive)
Attach a TtsSpan to the supplied Spannable at the indicated location,
 annotating that location as containing a phone number.
| Parameters | |
|---|---|
| s | Spannable: ASpannableto annotate. | 
| start | int: The starting character position of the phone number ins. | 
| endExclusive | int: The position after the ending character in the phone numbers. | 
areSamePhoneNumber
public static boolean areSamePhoneNumber (String number1, String number2, String defaultCountryIso)
Determines if two phone numbers are the same.
Matching is based on compare(java.lang.String, java.lang.String), matching takes into account national dialing plans rather than simply matching the last 7 digits of the two phone numbers. As a result, it is expected that some numbers which would match using the previous method will no longer match using this new approach.
| Parameters | |
|---|---|
| number1 | String: This value cannot benull. | 
| number2 | String: This value cannot benull. | 
| defaultCountryIso | String: The lowercase two letter ISO 3166-1 country code. Used when parsing
                          the phone numbers where it is not possible to determine the country
                          associated with a phone number based on the number alone. It
                          is recommended to pass inTelephonyManager.getNetworkCountryIso().
 This value cannot benull. | 
| Returns | |
|---|---|
| boolean | True if the two given phone number are same. | 
calledPartyBCDFragmentToString
public static String calledPartyBCDFragmentToString (byte[] bytes, int offset, int length, int bcdExtType)
Like calledPartyBCDToString, but field does not start with a TOA byte. For example: SIM ADN extension fields
| Parameters | |
|---|---|
| bytes | byte | 
| offset | int | 
| length | int | 
| bcdExtType | int: Value isBCD_EXTENDED_TYPE_EF_ADN, orBCD_EXTENDED_TYPE_CALLED_PARTY | 
| Returns | |
|---|---|
| String | |
calledPartyBCDFragmentToString
public static String calledPartyBCDFragmentToString (byte[] bytes, int offset, int length)
      This method was deprecated
      in API level 28.
    use calledPartyBCDFragmentToString(byte[], int, int, int) instead.
 Calling this method is equivalent to calling
 calledPartyBCDFragmentToString(byte[], int, int, int) with
 BCD_EXTENDED_TYPE_EF_ADN as the extended type.
  
Like calledPartyBCDToString, but field does not start with a TOA byte. For example: SIM ADN extension fields
| Parameters | |
|---|---|
| bytes | byte | 
| offset | int | 
| length | int | 
| Returns | |
|---|---|
| String | |
calledPartyBCDToString
public static String calledPartyBCDToString (byte[] bytes, int offset, int length, int bcdExtType)
3GPP TS 24.008 10.5.4.7 Called Party BCD Number See Also TS 51.011 10.5.1 "dialing number/ssc string" and TS 11.11 "10.3.1 EF adn (Abbreviated dialing numbers)"
| Parameters | |
|---|---|
| bytes | byte: the data buffer | 
| offset | int: should point to the TOA (aka. TON/NPI) octet after the length byte | 
| length | int: is the number of bytes including TOA byte
                and must be at least 2 | 
| bcdExtType | int: used to determine the extended bcd coding
 Value isBCD_EXTENDED_TYPE_EF_ADN, orBCD_EXTENDED_TYPE_CALLED_PARTY | 
| Returns | |
|---|---|
| String | |
calledPartyBCDToString
public static String calledPartyBCDToString (byte[] bytes, int offset, int length)
      This method was deprecated
      in API level 28.
    use calledPartyBCDToString(byte[], int, int, int) instead. Calling this
 method is equivalent to calling calledPartyBCDToString(byte[], int, int) with
 BCD_EXTENDED_TYPE_EF_ADN as the extended type.
  
3GPP TS 24.008 10.5.4.7 Called Party BCD Number See Also TS 51.011 10.5.1 "dialing number/ssc string" and TS 11.11 "10.3.1 EF adn (Abbreviated dialing numbers)"
| Parameters | |
|---|---|
| bytes | byte: the data buffer | 
| offset | int: should point to the TOA (aka. TON/NPI) octet after the length byte | 
| length | int: is the number of bytes including TOA byte
                and must be at least 2 | 
| Returns | |
|---|---|
| String | partial string on invalid decode | 
compare
public static boolean compare (Context context, String a, String b)
      This method was deprecated
      in API level 31.
    use areSamePhoneNumber(java.lang.String, java.lang.String, java.lang.String) instead
  
Compare phone numbers a and b, and return true if they're identical enough for caller ID purposes. Checks a resource to determine whether to use a strict or loose comparison algorithm.
| Parameters | |
|---|---|
| context | Context | 
| a | String | 
| b | String | 
| Returns | |
|---|---|
| boolean | |
compare
public static boolean compare (String a, String b)
      This method was deprecated
      in API level 31.
    use areSamePhoneNumber(java.lang.String, java.lang.String, java.lang.String) instead
  
Compare phone numbers a and b, return true if they're identical enough for caller ID purposes.
| Parameters | |
|---|---|
| a | String | 
| b | String | 
| Returns | |
|---|---|
| boolean | |
convertKeypadLettersToDigits
public static String convertKeypadLettersToDigits (String input)
Translates any alphabetic letters (i.e. [A-Za-z]) in the specified phone number into the equivalent numeric digits, according to the phone keypad letter mapping described in ITU E.161 and ISO/IEC 9995-8.
| Parameters | |
|---|---|
| input | String | 
| Returns | |
|---|---|
| String | the input string, with alpha letters converted to numeric digits using the phone keypad letter mapping. For example, an input of "1-800-GOOG-411" will return "1-800-4664-411". | 
createTtsSpan
public static TtsSpan createTtsSpan (String phoneNumberString)
Create a TtsSpan for the supplied String.
| Parameters | |
|---|---|
| phoneNumberString | String: AStringthe entirety of which represents a phone number. | 
| Returns | |
|---|---|
| TtsSpan | A TtsSpanfor . | 
createTtsSpannable
public static CharSequence createTtsSpannable (CharSequence phoneNumber)
Wrap the supplied CharSequence with a TtsSpan, annotating it as
 containing a phone number in its entirety.
| Parameters | |
|---|---|
| phoneNumber | CharSequence: ACharSequencethe entirety of which represents a phone number. | 
| Returns | |
|---|---|
| CharSequence | A CharSequencewith appropriate annotations. | 
extractNetworkPortion
public static String extractNetworkPortion (String phoneNumber)
Extracts the network address portion and canonicalizes (filters out separators.) Network address portion is everything up to DTMF control digit separators (pause or wait), but without non-dialable characters. Please note that the GSM wild character is allowed in the result. This must be resolved before dialing. Returns null if phoneNumber == null
| Parameters | |
|---|---|
| phoneNumber | String | 
| Returns | |
|---|---|
| String | |
extractPostDialPortion
public static String extractPostDialPortion (String phoneNumber)
Extracts the post-dial sequence of DTMF control digits, pauses, and waits. Strips separators. This string may be empty, but will not be null unless phoneNumber == null. Returns null if phoneNumber == null
| Parameters | |
|---|---|
| phoneNumber | String | 
| Returns | |
|---|---|
| String | |
formatJapaneseNumber
public static void formatJapaneseNumber (Editable text)
      This method was deprecated
      in API level 21.
    Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead
  
Formats a phone number in-place using the Japanese formatting rules. Numbers will be formatted as:
 03-xxxx-xxxx
 090-xxxx-xxxx
 0120-xxx-xxx
 +81-3-xxxx-xxxx
 +81-90-xxxx-xxxx
 
| Parameters | |
|---|---|
| text | Editable: the number to be formatted, will be modified with
 the formatting | 
formatNanpNumber
public static void formatNanpNumber (Editable text)
      This method was deprecated
      in API level 21.
    Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead
  
Formats a phone number in-place using the NANP formatting rules. Numbers will be formatted as:
 xxxxx
 xxx-xxxx
 xxx-xxx-xxxx
 1-xxx-xxx-xxxx
 +1-xxx-xxx-xxxx
 
| Parameters | |
|---|---|
| text | Editable: the number to be formatted, will be modified with the formatting | 
formatNumber
public static String formatNumber (String phoneNumber, String phoneNumberE164, String defaultCountryIso)
Format the phone number only if the given number hasn't been formatted.
The number which has only dailable character is treated as not being formatted.
| Parameters | |
|---|---|
| phoneNumber | String: the number to be formatted. | 
| phoneNumberE164 | String: the E164 format number whose country code is used if the given
            phoneNumber doesn't have the country code. | 
| defaultCountryIso | String: the ISO 3166-1 two letters country code whose convention will
            be used if the phoneNumberE164 is null or invalid, or if phoneNumber
            contains IDD. | 
| Returns | |
|---|---|
| String | the formatted number if the given number has been formatted, otherwise, return the given number. | 
formatNumber
public static void formatNumber (Editable text, int defaultFormattingType)
      This method was deprecated
      in API level 21.
    Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead
  
Formats a phone number in-place. Currently FORMAT_JAPAN and FORMAT_NANP
 is supported as a second argument.
| Parameters | |
|---|---|
| text | Editable: The number to be formatted, will be modified with the formatting | 
| defaultFormattingType | int: The default formatting rules to apply if the number does
 not begin with +[country_code] | 
formatNumber
public static String formatNumber (String source)
      This method was deprecated
      in API level 21.
    Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead
  
Breaks the given number down and formats it according to the rules for the country the number is from.
| Parameters | |
|---|---|
| source | String: The phone number to format | 
| Returns | |
|---|---|
| String | A locally acceptable formatting of the input, or the raw input if formatting rules aren't known for the number | 
formatNumber
public static String formatNumber (String phoneNumber, String defaultCountryIso)
Format a phone number.
If the given number doesn't have the country code, the phone will be formatted to the default country's convention.
| Parameters | |
|---|---|
| phoneNumber | String: the number to be formatted. | 
| defaultCountryIso | String: the ISO 3166-1 two letters country code whose convention will
            be used if the given number doesn't have the country code. | 
| Returns | |
|---|---|
| String | the formatted number, or null if the given number is not valid. | 
formatNumberToE164
public static String formatNumberToE164 (String phoneNumber, String defaultCountryIso)
Formats the specified phoneNumber to the E.164 representation.
| Parameters | |
|---|---|
| phoneNumber | String: the phone number to format. | 
| defaultCountryIso | String: the ISO 3166-1 two letters country code in UPPER CASE. | 
| Returns | |
|---|---|
| String | the E.164 representation, or null if the given phone number is not valid. | 
formatNumberToRFC3966
public static String formatNumberToRFC3966 (String phoneNumber, String defaultCountryIso)
Formats the specified phoneNumber to the RFC3966 representation.
| Parameters | |
|---|---|
| phoneNumber | String: the phone number to format. | 
| defaultCountryIso | String: the ISO 3166-1 two letters country code in UPPER CASE. | 
| Returns | |
|---|---|
| String | the RFC3966 representation, or null if the given phone number is not valid. | 
getFormatTypeForLocale
public static int getFormatTypeForLocale (Locale locale)
      This method was deprecated
      in API level 21.
    Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead
  
Returns the phone number formatting type for the given locale.
| Parameters | |
|---|---|
| locale | Locale: The locale of interest, usuallyLocale.getDefault() | 
| Returns | |
|---|---|
| int | The formatting type for the given locale, or FORMAT_UNKNOWN if the formatting rules are not known for the given locale | 
getNumberFromIntent
public static String getNumberFromIntent (Intent intent, Context context)
Extracts the phone number from an Intent.
| Parameters | |
|---|---|
| intent | Intent: the intent to get the number of | 
| context | Context: a context to use for database access | 
| Returns | |
|---|---|
| String | the phone number that would be called by the intent, or nullif the number cannot be found. | 
getStrippedReversed
public static String getStrippedReversed (String phoneNumber)
Returns the network portion reversed. This string is intended to go into an index column for a database lookup. Returns null if phoneNumber == null
| Parameters | |
|---|---|
| phoneNumber | String | 
| Returns | |
|---|---|
| String | |
is12Key
public static final boolean is12Key (char c)
True if c is ISO-LATIN characters 0-9, *, #
| Parameters | |
|---|---|
| c | char | 
| Returns | |
|---|---|
| boolean | |
isDialable
public static final boolean isDialable (char c)
True if c is ISO-LATIN characters 0-9, *, # , +, WILD
| Parameters | |
|---|---|
| c | char | 
| Returns | |
|---|---|
| boolean | |
isEmergencyNumber
public static boolean isEmergencyNumber (String number)
      This method was deprecated
      in API level 29.
    Please use TelephonyManager.isEmergencyNumber(String) instead.
  
Checks a given number against the list of emergency numbers provided by the RIL and SIM card.
| Parameters | |
|---|---|
| number | String: the number to look up. | 
| Returns | |
|---|---|
| boolean | true if the number is in the list of emergency numbers listed in the RIL / SIM, otherwise return false. | 
isGlobalPhoneNumber
public static boolean isGlobalPhoneNumber (String phoneNumber)
| Parameters | |
|---|---|
| phoneNumber | String | 
| Returns | |
|---|---|
| boolean | |
isISODigit
public static boolean isISODigit (char c)
True if c is ISO-LATIN characters 0-9
| Parameters | |
|---|---|
| c | char | 
| Returns | |
|---|---|
| boolean | |
isLocalEmergencyNumber
public static boolean isLocalEmergencyNumber (Context context, String number)
      This method was deprecated
      in API level 29.
    Please use TelephonyManager.isEmergencyNumber(String)
             instead.
  
Checks if a given number is an emergency number for the country that the user is in.
| Parameters | |
|---|---|
| context | Context: the specific context which the number should be checked against | 
| number | String: the number to look up. | 
| Returns | |
|---|---|
| boolean | true if the specified number is an emergency number for the country the user is currently in. | 
isNonSeparator
public static final boolean isNonSeparator (char c)
True if c is ISO-LATIN characters 0-9, *, # , +, WILD, WAIT, PAUSE
| Parameters | |
|---|---|
| c | char | 
| Returns | |
|---|---|
| boolean | |
isReallyDialable
public static final boolean isReallyDialable (char c)
True if c is ISO-LATIN characters 0-9, *, # , + (no WILD)
| Parameters | |
|---|---|
| c | char | 
| Returns | |
|---|---|
| boolean | |
isStartsPostDial
public static final boolean isStartsPostDial (char c)
This any anything to the right of this char is part of the post-dial string (eg this is PAUSE or WAIT)
| Parameters | |
|---|---|
| c | char | 
| Returns | |
|---|---|
| boolean | |
isVoiceMailNumber
public static boolean isVoiceMailNumber (String number)
isVoiceMailNumber: checks a given number against the voicemail number provided by the RIL and SIM card. The caller must have the READ_PHONE_STATE credential.
| Parameters | |
|---|---|
| number | String: the number to look up. | 
| Returns | |
|---|---|
| boolean | true if the number is in the list of voicemail. False otherwise, including if the caller does not have the permission to read the VM number. | 
isWellFormedSmsAddress
public static boolean isWellFormedSmsAddress (String address)
Return true iff the network portion of address is,
 as far as we can tell on the device, suitable for use as an SMS
 destination address.
| Parameters | |
|---|---|
| address | String | 
| Returns | |
|---|---|
| boolean | |
isWpsCallNumber
public static boolean isWpsCallNumber (String number)
Check if the number is for Wireless Priority Service call.
| Parameters | |
|---|---|
| number | String: The phone number used for WPS call.
 This value cannot benull. | 
| Returns | |
|---|---|
| boolean | trueif number matches WPS pattern andfalseotherwise. | 
networkPortionToCalledPartyBCD
public static byte[] networkPortionToCalledPartyBCD (String s)
Note: calls extractNetworkPortion(), so do not use for SIM EF[ADN] style records Returns null if network portion is empty.
| Parameters | |
|---|---|
| s | String | 
| Returns | |
|---|---|
| byte[] | |
networkPortionToCalledPartyBCDWithLength
public static byte[] networkPortionToCalledPartyBCDWithLength (String s)
Same as networkPortionToCalledPartyBCD(String), but includes a
 one-byte length prefix.
| Parameters | |
|---|---|
| s | String | 
| Returns | |
|---|---|
| byte[] | |
normalizeNumber
public static String normalizeNumber (String phoneNumber)
Normalize a phone number by removing the characters other than digits. If the given number has keypad letters, the letters will be converted to digits first.
| Parameters | |
|---|---|
| phoneNumber | String: the number to be normalized. | 
| Returns | |
|---|---|
| String | the normalized number. | 
numberToCalledPartyBCD
public static byte[] numberToCalledPartyBCD (String number, int bcdExtType)
Convert a dialing number to BCD byte array
| Parameters | |
|---|---|
| number | String: dialing number string. If the dialing number starts with '+', set to
 international TOA | 
| bcdExtType | int: used to determine the extended bcd coding
 Value isBCD_EXTENDED_TYPE_EF_ADN, orBCD_EXTENDED_TYPE_CALLED_PARTY | 
| Returns | |
|---|---|
| byte[] | BCD byte array | 
numberToCalledPartyBCD
public static byte[] numberToCalledPartyBCD (String number)
      This method was deprecated
      in API level 28.
    use numberToCalledPartyBCD(java.lang.String, int) instead. Calling this method
 is equivalent to calling numberToCalledPartyBCD(java.lang.String, int) with
 BCD_EXTENDED_TYPE_EF_ADN as the extended type.
  
Convert a dialing number to BCD byte array
| Parameters | |
|---|---|
| number | String: dialing number string. If the dialing number starts with '+', set to
 international TOA | 
| Returns | |
|---|---|
| byte[] | BCD byte array | 
replaceUnicodeDigits
public static String replaceUnicodeDigits (String number)
Replaces all unicode(e.g. Arabic, Persian) digits with their decimal digit equivalents.
| Parameters | |
|---|---|
| number | String: the number to perform the replacement on. | 
| Returns | |
|---|---|
| String | the replaced number. | 
stringFromStringAndTOA
public static String stringFromStringAndTOA (String s, int TOA)
Basically: makes sure there's a + in front of a TOA_International number Returns null if s == null
| Parameters | |
|---|---|
| s | String | 
| TOA | int | 
| Returns | |
|---|---|
| String | |
stripSeparators
public static String stripSeparators (String phoneNumber)
Strips separators from a phone number string.
| Parameters | |
|---|---|
| phoneNumber | String: phone number to strip. | 
| Returns | |
|---|---|
| String | phone string stripped of separators. | 
toCallerIDMinMatch
public static String toCallerIDMinMatch (String phoneNumber)
Returns the rightmost minimum matched characters in the network portion in *reversed* order This can be used to do a database lookup against the column that stores getStrippedReversed() Returns null if phoneNumber == null
| Parameters | |
|---|---|
| phoneNumber | String | 
| Returns | |
|---|---|
| String | |
toaFromString
public static int toaFromString (String s)
Returns the TOA for the given dial string Basically, returns TOA_International if there's a + prefix
| Parameters | |
|---|---|
| s | String | 
| Returns | |
|---|---|
| int | |
