# TelephonyManagerCompat

# TelephonyManagerCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/telephony/TelephonyManagerCompat.java+class:androidx.core.telephony.TelephonyManagerCompat)  
Added in[1.6.0](https://developer.android.com/jetpack/androidx/releases/core#1.6.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/telephony/TelephonyManagerCompat "View this page in Java")

<br />

```
class TelephonyManagerCompat
```

<br />

*** ** * ** ***

Helper for accessing features in[TelephonyManager](https://developer.android.com/reference/android/telephony/TelephonyManager.html).

## Summary

|                                        ### Public functions                                        |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | `@`[RequiresPermission](https://developer.android.com/reference/kotlin/androidx/annotation/RequiresPermission)`(value = `[android.Manifest.permission.READ_PHONE_STATE](https://developer.android.com/reference/android/android.Manifest.permission.html#READ_PHONE_STATE)`)` [getImei](https://developer.android.com/reference/kotlin/androidx/core/telephony/TelephonyManagerCompat#getImei(android.telephony.TelephonyManager))`(telephonyManager: `[TelephonyManager](https://developer.android.com/reference/android/telephony/TelephonyManager.html)`)` Returns the IMEI (International Mobile Equipment Identity) associated with the subscription id of the given TelephonyManager, or null if not available. |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [getSubscriptionId](https://developer.android.com/reference/kotlin/androidx/core/telephony/TelephonyManagerCompat#getSubscriptionId(android.telephony.TelephonyManager))`(telephonyManager: `[TelephonyManager](https://developer.android.com/reference/android/telephony/TelephonyManager.html)`)` Return the subscription ID the TelephonyManager was created with (via[createForSubscriptionId](https://developer.android.com/reference/android/telephony/TelephonyManager.html#createForSubscriptionId(int))) if applicable, and otherwise the default subscription ID.                                                                                                                                           |

## Public functions

### getImei

Added in[1.6.0](https://developer.android.com/jetpack/androidx/releases/core#1.6.0)  

```
@RequiresPermission(value = android.Manifest.permission.READ_PHONE_STATE)
java-static fun getImei(telephonyManager: TelephonyManager): String?
```

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](https://developer.android.com/reference/android/telephony/TelephonyManager.html#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](https://developer.android.com/reference/android/telephony/TelephonyManager.html#hasCarrierPrivileges()))
- the caller is the default SMS role holder (see[isRoleHeld](https://developer.android.com/reference/android/app/role/RoleManager.html#isRoleHeld(java.lang.String)))
- the caller holds the USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permission  

### getSubscriptionId

Added in[1.6.0](https://developer.android.com/jetpack/androidx/releases/core#1.6.0)  

```
java-static fun getSubscriptionId(telephonyManager: TelephonyManager): Int
```

Return the subscription ID the TelephonyManager was created with (via[createForSubscriptionId](https://developer.android.com/reference/android/telephony/TelephonyManager.html#createForSubscriptionId(int))) if applicable, and otherwise the default subscription ID.