Added in API level 31

ServiceStateListener


interface ServiceStateListener
android.telephony.TelephonyCallback.ServiceStateListener

Interface for service state listener.

Summary

Public methods
abstract Unit

Callback invoked when device service state changes on the registered subscription.

Public methods

onServiceStateChanged

Added in API level 31
abstract fun onServiceStateChanged(serviceState: ServiceState): Unit

Callback invoked when device service state changes on the registered subscription. Note, the registration subscription ID comes from TelephonyManager object which registers TelephonyCallback by TelephonyManager#registerTelephonyCallback(Executor, TelephonyCallback). If this TelephonyManager object was created with TelephonyManager#createForSubscriptionId(int), then the callback applies to the subscription ID. Otherwise, this callback applies to SubscriptionManager#getDefaultSubscriptionId().

The instance of 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 Manifest.permission#ACCESS_FINE_LOCATION permission will receive all the information in ServiceState, otherwise the cellIdentity will be null if apps only holding the Manifest.permission#ACCESS_COARSE_LOCATION permission. Network operator name in long/short alphanumeric format and numeric id will be null if apps holding neither android.Manifest.permission#ACCESS_FINE_LOCATION

Parameters
serviceState ServiceState: This value cannot be null.