java.lang.Object | |
↳ | android.telephony.PhoneNumberUtils |
Various utilities for dealing with phone number strings.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FORMAT_JAPAN | Japanese formatting | |||||||||
int | FORMAT_NANP | NANP formatting | |||||||||
int | FORMAT_UNKNOWN | The 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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Like calledPartyBCDToString, but field does not start with a
TOA byte.
| |||||||||||
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)"
| |||||||||||
Compare phone numbers a and b, return true if they're identical enough for caller ID purposes.
| |||||||||||
Compare phone numbers a and b, and return true if they're identical
enough for caller ID purposes.
| |||||||||||
Translates any alphabetic letters (i.e.
| |||||||||||
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.
| |||||||||||
Extracts the post-dial sequence of DTMF control digits, pauses, and
waits.
| |||||||||||
This method is deprecated.
Use
formatNumber(String, String) instead
| |||||||||||
This method is deprecated.
Use
formatNumber(String, String) instead
| |||||||||||
This method is deprecated.
Use
formatNumber(String, String) instead
| |||||||||||
Format a phone number.
| |||||||||||
Format the phone number only if the given number hasn't been formatted.
| |||||||||||
This method is deprecated.
Use
formatNumber(String, String) instead
| |||||||||||
Format the given phoneNumber to the E.164 representation.
| |||||||||||
This method is deprecated.
Use
formatNumber(String, String) instead
| |||||||||||
Extracts the phone number from an Intent.
| |||||||||||
Returns the network portion reversed.
| |||||||||||
True if c is ISO-LATIN characters 0-9, *, #
| |||||||||||
True if c is ISO-LATIN characters 0-9, *, # , +, WILD
| |||||||||||
Checks a given number against the list of
emergency numbers provided by the RIL and SIM card.
| |||||||||||
True if c is ISO-LATIN characters 0-9
| |||||||||||
Checks if a given number is an emergency number for the country that the user is in.
| |||||||||||
True if c is ISO-LATIN characters 0-9, *, # , +, WILD, WAIT, PAUSE
| |||||||||||
True if c is ISO-LATIN characters 0-9, *, # , + (no WILD)
| |||||||||||
This any anything to the right of this char is part of the
post-dial string (eg this is PAUSE or WAIT)
| |||||||||||
isVoiceMailNumber: checks a given number against the voicemail
number provided by the RIL and SIM card.
| |||||||||||
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. | |||||||||||
Note: calls extractNetworkPortion(), so do not use for
SIM EF[ADN] style records
Returns null if network portion is empty.
| |||||||||||
Same as
networkPortionToCalledPartyBCD(String) , but includes a
one-byte length prefix. | |||||||||||
Normalize a phone number by removing the characters other than digits.
| |||||||||||
Convert a dialing number to BCD byte array
| |||||||||||
Replaces all unicode(e.g.
| |||||||||||
Basically: makes sure there's a + in front of a
TOA_International number
Returns null if s == null
| |||||||||||
Strips separators from a phone number string.
| |||||||||||
Returns the rightmost MIN_MATCH (5) 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
| |||||||||||
Returns the TOA for the given dial string
Basically, returns TOA_International if there's a + prefix
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Japanese formatting
NANP formatting
The current locale is unknown, look for a country code or don't format
Like calledPartyBCDToString, but field does not start with a TOA byte. For example: SIM ADN extension fields
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)"
bytes | the data buffer |
---|---|
offset | should point to the TOA (aka. TON/NPI) octet after the length byte |
length | is the number of bytes including TOA byte and must be at least 2 |
Compare phone numbers a and b, return true if they're identical enough for caller ID purposes.
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.
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.
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
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
This method is deprecated.
Use formatNumber(String, String)
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
text | the number to be formatted, will be modified with the formatting |
---|
This method is deprecated.
Use formatNumber(String, String)
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
text | the number to be formatted, will be modified with the formatting |
---|
This method is deprecated.
Use formatNumber(String, String)
instead
Breaks the given number down and formats it according to the rules for the country the number is from.
source | The phone number to format |
---|
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.
phoneNumber | the number to be formatted. |
---|---|
defaultCountryIso | the ISO 3166-1 two letters country code whose convention will be used if the given number doesn't have the country code. |
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.
phoneNumber | the number to be formatted. |
---|---|
phoneNumberE164 | the E164 format number whose country code is used if the given phoneNumber doesn't have the country code. |
defaultCountryIso | 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. |
This method is deprecated.
Use formatNumber(String, String)
instead
Formats a phone number in-place. Currently FORMAT_JAPAN
and FORMAT_NANP
is supported as a second argument.
text | The number to be formatted, will be modified with the formatting |
---|---|
defaultFormattingType | The default formatting rules to apply if the number does not begin with +[country_code] |
Format the given phoneNumber to the E.164 representation.
The given phone number must have an area code and could have a country code.
The defaultCountryIso is used to validate the given number and generate the E.164 phone number if the given number doesn't have a country code.
phoneNumber | the phone number to format |
---|---|
defaultCountryIso | the ISO 3166-1 two letters country code |
This method is deprecated.
Use formatNumber(String, String)
instead
Returns the phone number formatting type for the given locale.
locale | The locale of interest, usually getDefault() |
---|
Extracts the phone number from an Intent.
intent | the intent to get the number of |
---|---|
context | a context to use for database access |
null
if the number cannot be found.
Returns the network portion reversed. This string is intended to go into an index column for a database lookup. Returns null if phoneNumber == null
True if c is ISO-LATIN characters 0-9, *, #
True if c is ISO-LATIN characters 0-9, *, # , +, WILD
Checks a given number against the list of emergency numbers provided by the RIL and SIM card.
number | the number to look up. |
---|
True if c is ISO-LATIN characters 0-9
Checks if a given number is an emergency number for the country that the user is in.
context | the specific context which the number should be checked against |
---|---|
number | the number to look up. |
True if c is ISO-LATIN characters 0-9, *, # , +, WILD, WAIT, PAUSE
True if c is ISO-LATIN characters 0-9, *, # , + (no WILD)
This any anything to the right of this char is part of the post-dial string (eg this is PAUSE or WAIT)
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.
number | the number to look up. |
---|
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.
Note: calls extractNetworkPortion(), so do not use for SIM EF[ADN] style records Returns null if network portion is empty.
Same as networkPortionToCalledPartyBCD(String)
, but includes a
one-byte length prefix.
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.
phoneNumber | the number to be normalized. |
---|
Convert a dialing number to BCD byte array
number | dialing number string if the dialing number starts with '+', set to international TOA |
---|
Replaces all unicode(e.g. Arabic, Persian) digits with their decimal digit equivalents.
number | the number to perform the replacement on. |
---|
Basically: makes sure there's a + in front of a TOA_International number Returns null if s == null
Strips separators from a phone number string.
phoneNumber | phone number to strip. |
---|
Returns the rightmost MIN_MATCH (5) 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
Returns the TOA for the given dial string Basically, returns TOA_International if there's a + prefix