Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

# TelephonyCallback.ServiceStateListener

*** ** * ** ***

` public static interface TelephonyCallback.ServiceStateListener `   
` `

|---|
| android.telephony.TelephonyCallback.ServiceStateListener |

<br />

*** ** * ** ***

Interface for service state listener.

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/telephony/TelephonyCallback.ServiceStateListener#onServiceStateChanged(android.telephony.ServiceState)(https://developer.android.com/reference/android/telephony/ServiceState serviceState) ` Callback invoked when device service state changes on the registered subscription. |

## Public methods

### onServiceStateChanged

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onServiceStateChanged (ServiceState serviceState)
```

Callback invoked when device service state changes on the registered subscription. Note, the registration subscription ID comes from `https://developer.android.com/reference/android/telephony/TelephonyManager` object which registers TelephonyCallback by `https://developer.android.com/reference/android/telephony/TelephonyManager#registerTelephonyCallback(java.util.concurrent.Executor,%20android.telephony.TelephonyCallback)`. If this TelephonyManager object was created with `https://developer.android.com/reference/android/telephony/TelephonyManager#createForSubscriptionId(int)`, then the callback applies to the subscription ID. Otherwise, this callback applies to `https://developer.android.com/reference/android/telephony/SubscriptionManager#getDefaultSubscriptionId()`.

The instance of `https://developer.android.com/reference/android/telephony/ServiceState` passed as an argument here will have various levels of location information stripped from it depending on the location permissions that your app holds. Only apps holding the `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION` permission will receive all the information in `https://developer.android.com/reference/android/telephony/ServiceState`, otherwise the cellIdentity will be null if apps only holding the `https://developer.android.com/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION` permission. Network operator name in long/short alphanumeric format and numeric id will be null if apps holding neither `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`

<br />

| Parameters ||
|---|---|
| `serviceState` | `ServiceState`: This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/telephony/ServiceState#STATE_EMERGENCY_ONLY`
- `https://developer.android.com/reference/android/telephony/ServiceState#STATE_IN_SERVICE`
- `https://developer.android.com/reference/android/telephony/ServiceState#STATE_OUT_OF_SERVICE`
- `https://developer.android.com/reference/android/telephony/ServiceState#STATE_POWER_OFF`