Sdílet prostřednictvím


PhoneNumberUtils.FormatNumber Method

Definition

Overloads

FormatNumber(String)
Obsolete.

Breaks the given number down and formats it according to the rules for the country the number is from.

FormatNumber(IEditable, PhoneNumberFormat)
Obsolete.

Formats a phone number in-place.

FormatNumber(String, String)

Format a phone number.

FormatNumber(String, String, String)

Format the phone number only if the given number hasn't been formatted.

FormatNumber(String)

Caution

deprecated

Breaks the given number down and formats it according to the rules for the country the number is from.

[Android.Runtime.Register("formatNumber", "(Ljava/lang/String;)Ljava/lang/String;", "")]
[System.Obsolete("deprecated")]
public static string? FormatNumber (string? source);
[<Android.Runtime.Register("formatNumber", "(Ljava/lang/String;)Ljava/lang/String;", "")>]
[<System.Obsolete("deprecated")>]
static member FormatNumber : string -> string

Parameters

source
String

The phone number to format

Returns

A locally acceptable formatting of the input, or the raw input if formatting rules aren't known for the number

Attributes

Remarks

Breaks the given number down and formats it according to the rules for the country the number is from.

This member is deprecated. Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead

Java documentation for android.telephony.PhoneNumberUtils.formatNumber(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

FormatNumber(IEditable, PhoneNumberFormat)

Caution

deprecated

Formats a phone number in-place.

[Android.Runtime.Register("formatNumber", "(Landroid/text/Editable;I)V", "")]
[System.Obsolete("deprecated")]
public static void FormatNumber (Android.Text.IEditable? text, Android.Telephony.PhoneNumberFormat defaultFormattingType);
[<Android.Runtime.Register("formatNumber", "(Landroid/text/Editable;I)V", "")>]
[<System.Obsolete("deprecated")>]
static member FormatNumber : Android.Text.IEditable * Android.Telephony.PhoneNumberFormat -> unit

Parameters

text
IEditable

The number to be formatted, will be modified with the formatting

defaultFormattingType
PhoneNumberFormat

The default formatting rules to apply if the number does not begin with +[country_code]

Attributes

Remarks

Formats a phone number in-place. Currently #FORMAT_JAPAN and #FORMAT_NANP is supported as a second argument.

This member is deprecated. Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead

Java documentation for android.telephony.PhoneNumberUtils.formatNumber(android.text.Editable, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

FormatNumber(String, String)

Format a phone number.

[Android.Runtime.Register("formatNumber", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "")]
public static string? FormatNumber (string? phoneNumber, string? defaultCountryIso);
[<Android.Runtime.Register("formatNumber", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "")>]
static member FormatNumber : string * string -> string

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

the formatted number, or null if the given number is not valid.

Attributes

Remarks

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.

Java documentation for android.telephony.PhoneNumberUtils.formatNumber(java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

FormatNumber(String, String, String)

Format the phone number only if the given number hasn't been formatted.

[Android.Runtime.Register("formatNumber", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "")]
public static string? FormatNumber (string? phoneNumber, string? phoneNumberE164, string? defaultCountryIso);
[<Android.Runtime.Register("formatNumber", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "")>]
static member FormatNumber : string * string * string -> string

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

the formatted number if the given number has been formatted, otherwise, return the given number.

Attributes

Remarks

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.

Java documentation for android.telephony.PhoneNumberUtils.formatNumber(java.lang.String, java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to