SubscriptionManager.GetPhoneNumber Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetPhoneNumber(Int32) |
Returns the phone number for the given |
GetPhoneNumber(Int32, Int32) |
Returns the phone number for the given |
GetPhoneNumber(Int32)
Returns the phone number for the given subId
, or an empty string if
not available.
[Android.Runtime.Register("getPhoneNumber", "(I)Ljava/lang/String;", "GetGetPhoneNumber_IHandler", ApiSince=33)]
public virtual string GetPhoneNumber (int subscriptionId);
[<Android.Runtime.Register("getPhoneNumber", "(I)Ljava/lang/String;", "GetGetPhoneNumber_IHandler", ApiSince=33)>]
abstract member GetPhoneNumber : int -> string
override this.GetPhoneNumber : int -> string
Parameters
- subscriptionId
- Int32
the subscription ID, or #DEFAULT_SUBSCRIPTION_ID
for the default one.
Returns
the phone number, or an empty string if not available.
- Attributes
Remarks
Returns the phone number for the given subId
, or an empty string if not available.
This API is suitable for general apps that needs to know the phone number. For specific apps that needs to know the phone number provided by a specific source, #getPhoneNumber(int, int)
may be suitable.
This API is built up on #getPhoneNumber(int, int)
, but picks from available sources in the following order: #PHONE_NUMBER_SOURCE_CARRIER
> #PHONE_NUMBER_SOURCE_UICC
> #PHONE_NUMBER_SOURCE_IMS
.
The API provides no guarantees of what format the number is in: the format can vary depending on the underlying source and the network etc. Programmatic parsing should be done cautiously, for example, after formatting the number to a consistent format with android.telephony.PhoneNumberUtils#formatNumberToE164(String, String)
.
The availability and correctness of the phone number depends on the underlying source and the network etc. Additional verification is needed to use this number for security-related or other sensitive scenarios.
Java documentation for android.telephony.SubscriptionManager.getPhoneNumber(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
GetPhoneNumber(Int32, Int32)
Returns the phone number for the given subscriptionId
and source
,
or an empty string if not available.
[Android.Runtime.Register("getPhoneNumber", "(II)Ljava/lang/String;", "GetGetPhoneNumber_IIHandler", ApiSince=33)]
public virtual string GetPhoneNumber (int subscriptionId, int source);
[<Android.Runtime.Register("getPhoneNumber", "(II)Ljava/lang/String;", "GetGetPhoneNumber_IIHandler", ApiSince=33)>]
abstract member GetPhoneNumber : int * int -> string
override this.GetPhoneNumber : int * int -> string
Parameters
- subscriptionId
- Int32
the subscription ID, or #DEFAULT_SUBSCRIPTION_ID
for the default one.
- source
- Int32
the source of the phone number, one of the PHONE_NUMBER_SOURCE_* constants.
Returns
the phone number, or an empty string if not available.
- Attributes
Remarks
Returns the phone number for the given subscriptionId
and source
, or an empty string if not available.
General apps that need to know the phone number should use #getPhoneNumber(int)
instead. This API may be suitable specific apps that needs to know the phone number from a specific source. For example, a carrier app needs to know exactly what's on #PHONE_NUMBER_SOURCE_UICC UICC
and decide if the previously set phone number of source #PHONE_NUMBER_SOURCE_CARRIER carrier
should be updated.
The API provides no guarantees of what format the number is in: the format can vary depending on the source
and the network etc. Programmatic parsing should be done cautiously, for example, after formatting the number to a consistent format with android.telephony.PhoneNumberUtils#formatNumberToE164(String, String)
.
Note the assumption is that one subscription (which usually means one SIM) has only one phone number. The multiple sources backup each other so hopefully at least one is availavle. For example, for a carrier that doesn't typically set phone numbers on #PHONE_NUMBER_SOURCE_UICC UICC
, the source #PHONE_NUMBER_SOURCE_IMS IMS
may provide one. Or, a carrier may decide to provide the phone number via source #PHONE_NUMBER_SOURCE_CARRIER carrier
if neither source UICC nor IMS is available.
The availability and correctness of the phone number depends on the underlying source and the network etc. Additional verification is needed to use this number for security-related or other sensitive scenarios.
Java documentation for android.telephony.SubscriptionManager.getPhoneNumber(int, 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.