TelephonyManagerCompat

public class TelephonyManagerCompat
extends Object

java.lang.Object
   ↳ androidx.core.telephony.TelephonyManagerCompat


Helper for accessing features in TelephonyManager.

Summary

Public methods

static String getImei(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 getSubscriptionId(TelephonyManager telephonyManager)

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

Inherited methods

Public methods

getImei

public static String getImei (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:

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 TelephonyManager.hasCarrierPrivileges())
  • the caller is the default SMS role holder (see RoleManager.isRoleHeld(String))
  • the caller holds the USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permission

Requires the READ_PHONE_STATE permission.

Parameters
telephonyManager TelephonyManager

Returns
String

getSubscriptionId

public static int getSubscriptionId (TelephonyManager telephonyManager)

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

Parameters
telephonyManager TelephonyManager

Returns
int