Stay organized with collections
Save and categorize content based on your preferences.
ServiceStateListener
interface ServiceStateListener
Interface for service state listener.
Summary
Public methods |
abstract Unit |
Callback invoked when device service state changes on the registered subscription.
|
Public methods
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# TelephonyCallback.ServiceStateListener\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nServiceStateListener\n====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/telephony/TelephonyCallback.ServiceStateListener \"View this page in Java\") \n\n```\ninterface ServiceStateListener\n```\n\n|---------------------------------------------------------------|\n| [android.telephony.TelephonyCallback.ServiceStateListener](#) |\n\nInterface for service state listener.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onServiceStateChanged](#onServiceStateChanged(android.telephony.ServiceState))`(`serviceState:` `[ServiceState](/reference/kotlin/android/telephony/ServiceState)`)` Callback invoked when device service state changes on the registered subscription. |\n\nPublic methods\n--------------\n\n### onServiceStateChanged\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onServiceStateChanged(serviceState: ServiceState): Unit\n```\n\nCallback invoked when device service state changes on the registered subscription. Note, the registration subscription ID comes from [TelephonyManager](/reference/kotlin/android/telephony/TelephonyManager) object which registers TelephonyCallback by [TelephonyManager.registerTelephonyCallback(Executor, TelephonyCallback)](/reference/kotlin/android/telephony/TelephonyManager#registerTelephonyCallback(java.util.concurrent.Executor,%20android.telephony.TelephonyCallback)). If this TelephonyManager object was created with [TelephonyManager.createForSubscriptionId(int)](/reference/kotlin/android/telephony/TelephonyManager#createForSubscriptionId(kotlin.Int)), then the callback applies to the subscription ID. Otherwise, this callback applies to [SubscriptionManager.getDefaultSubscriptionId()](/reference/kotlin/android/telephony/SubscriptionManager#getDefaultSubscriptionId()).\n\nThe instance of [ServiceState](/reference/kotlin/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 [Manifest.permission.ACCESS_FINE_LOCATION](../Manifest.permission.html#ACCESS_FINE_LOCATION:kotlin.String) permission will receive all the information in [ServiceState](/reference/kotlin/android/telephony/ServiceState), otherwise the cellIdentity will be null if apps only holding the [Manifest.permission.ACCESS_COARSE_LOCATION](../Manifest.permission.html#ACCESS_COARSE_LOCATION:kotlin.String) 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](../Manifest.permission.html#ACCESS_FINE_LOCATION:kotlin.String)\n\n| Parameters ||\n|----------------|------------------------------------------------------------------------------------------------|\n| `serviceState` | [ServiceState](/reference/kotlin/android/telephony/ServiceState): This value cannot be `null`. |\n\n**See Also**\n\n- [android.telephony.ServiceState#STATE_EMERGENCY_ONLY](/reference/kotlin/android/telephony/ServiceState#STATE_EMERGENCY_ONLY:kotlin.Int)\n- [android.telephony.ServiceState#STATE_IN_SERVICE](/reference/kotlin/android/telephony/ServiceState#STATE_IN_SERVICE:kotlin.Int)\n- [android.telephony.ServiceState#STATE_OUT_OF_SERVICE](/reference/kotlin/android/telephony/ServiceState#STATE_OUT_OF_SERVICE:kotlin.Int)\n- [android.telephony.ServiceState#STATE_POWER_OFF](/reference/kotlin/android/telephony/ServiceState#STATE_POWER_OFF:kotlin.Int)"]]