Stay organized with collections
Save and categorize content based on your preferences.
TelephonyCallback.ServiceStateListener
public
static
interface
TelephonyCallback.ServiceStateListener
android.telephony.TelephonyCallback.ServiceStateListener
|
Interface for service state listener.
Summary
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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nTelephonyCallback.ServiceStateListener\n======================================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/telephony/TelephonyCallback.ServiceStateListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nTelephonyCallback.ServiceStateListener\n`\n\n\n`\n\n\n`\n\n|----------------------------------------------------------|\n| android.telephony.TelephonyCallback.ServiceStateListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInterface for service state listener.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onServiceStateChanged](/reference/android/telephony/TelephonyCallback.ServiceStateListener#onServiceStateChanged(android.telephony.ServiceState))`(`[ServiceState](/reference/android/telephony/ServiceState)` 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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onServiceStateChanged (ServiceState serviceState)\n```\n\nCallback invoked when device service state changes on the registered subscription.\nNote, the registration subscription ID comes from [TelephonyManager](/reference/android/telephony/TelephonyManager) object\nwhich registers TelephonyCallback by\n[TelephonyManager.registerTelephonyCallback(Executor, TelephonyCallback)](/reference/android/telephony/TelephonyManager#registerTelephonyCallback(java.util.concurrent.Executor,%20android.telephony.TelephonyCallback)).\nIf this TelephonyManager object was created with\n[TelephonyManager.createForSubscriptionId(int)](/reference/android/telephony/TelephonyManager#createForSubscriptionId(int)), then the callback applies to the\nsubscription ID. Otherwise, this callback applies to\n[SubscriptionManager.getDefaultSubscriptionId()](/reference/android/telephony/SubscriptionManager#getDefaultSubscriptionId()).\n\n\nThe instance of [ServiceState](/reference/android/telephony/ServiceState) passed as an argument here will have various\nlevels of location information stripped from it depending on the location permissions\nthat your app holds.\nOnly apps holding the [Manifest.permission.ACCESS_FINE_LOCATION](/reference/android/Manifest.permission#ACCESS_FINE_LOCATION) permission will\nreceive all the information in [ServiceState](/reference/android/telephony/ServiceState), otherwise the cellIdentity\nwill be null if apps only holding the [Manifest.permission.ACCESS_COARSE_LOCATION](/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION)\npermission. Network operator name in long/short alphanumeric format and numeric id will\nbe null if apps holding neither [Manifest.permission.ACCESS_FINE_LOCATION](/reference/android/Manifest.permission#ACCESS_FINE_LOCATION)\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------|-----------------------------------------------------|\n| `serviceState` | `ServiceState`: This value cannot be `null`. \u003cbr /\u003e |\n\n**See also:**\n\n- [ServiceState.STATE_EMERGENCY_ONLY](/reference/android/telephony/ServiceState#STATE_EMERGENCY_ONLY)\n- [ServiceState.STATE_IN_SERVICE](/reference/android/telephony/ServiceState#STATE_IN_SERVICE)\n- [ServiceState.STATE_OUT_OF_SERVICE](/reference/android/telephony/ServiceState#STATE_OUT_OF_SERVICE)\n- [ServiceState.STATE_POWER_OFF](/reference/android/telephony/ServiceState#STATE_POWER_OFF)"]]