TelephonyManager.DeviceId Property
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.
Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones.
public virtual string? DeviceId { [Android.Runtime.Register("getDeviceId", "()Ljava/lang/String;", "GetGetDeviceIdHandler")] [Android.Runtime.RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE")] get; }
[<get: Android.Runtime.Register("getDeviceId", "()Ljava/lang/String;", "GetGetDeviceIdHandler")>]
[<get: Android.Runtime.RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE")>]
member this.DeviceId : string
Property Value
- Attributes
Remarks
Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones. Return null if device ID is not available.
Starting with API level 29, persistent device identifiers are guarded behind additional restrictions, and apps are recommended to use resettable identifiers (see Best practices for unique identifiers). This method can be invoked if one of the following requirements is met: <ul> <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this is a privileged permission that can only be granted to apps preloaded on the device. <li>If the calling app is the device owner of a fully-managed device, a profile owner of an organization-owned device, or their delegates (see android.app.admin.DevicePolicyManager#getEnrollmentSpecificId()
). <li>If the calling app has carrier privileges (see #hasCarrierPrivileges
) on any active subscription. <li>If the calling app is the default SMS role holder (see RoleManager#isRoleHeld(String)
). </ul>
If the calling app does not meet one of these requirements then this method will behave as follows:
<ul> <li>If the calling app's target SDK is API level 28 or lower and the app has the READ_PHONE_STATE permission then null is returned.</li> <li>If the calling app's target SDK is API level 28 or lower and the app does not have the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or higher, then a SecurityException is thrown.</li> </ul>
This member is deprecated. Use #getImei
which returns IMEI for GSM or #getMeid
which returns MEID for CDMA.
Java documentation for android.telephony.TelephonyManager.getDeviceId()
.
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.