TelephonyManagerCompat

Added in 1.6.0

public class TelephonyManagerCompat


Helper for accessing features in TelephonyManager.

Summary

Public methods

static @Nullable String
@RequiresPermission(value = android.Manifest.permission.READ_PHONE_STATE)
getImei(@NonNull TelephonyManager telephonyManager)

Returns the IMEI (International Mobile Equipment Identity) associated with the subscription id of the given TelephonyManager, or null if not available.

static int

Return the subscription ID the TelephonyManager was created with (via createForSubscriptionId) if applicable, and otherwise the default subscription ID.

Public methods

getImei

Added in 1.6.0
@RequiresPermission(value = android.Manifest.permission.READ_PHONE_STATE)
public static @Nullable String getImei(@NonNull TelephonyManager telephonyManager)

Returns the IMEI (International Mobile Equipment Identity) associated with the subscription id of the given TelephonyManager, or null if not available.

Below Android 10, this API requires any of:

  • the caller holds the READ_PHONE_STATE permission
  • the caller has carrier privileges (see hasCarrierPrivileges)

On Android 10 and above, this API requires any of:

  • the caller holds the READ_PRIVILEGED_PHONE_STATE permission
  • the caller is the device or profile owner and holds the READ_PHONE_STATE permission
  • the caller has carrier privileges (see hasCarrierPrivileges)
  • the caller is the default SMS role holder (see isRoleHeld)
  • the caller holds the USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permission

getSubscriptionId

Added in 1.6.0
public static int getSubscriptionId(@NonNull TelephonyManager telephonyManager)

Return the subscription ID the TelephonyManager was created with (via createForSubscriptionId) if applicable, and otherwise the default subscription ID.