Added in API level 1

ServiceState


open class ServiceState : Parcelable
kotlin.Any
   ↳ android.telephony.ServiceState

Contains phone state and service related information. The following phone information is included in returned ServiceState:

  • Service state: IN_SERVICE, OUT_OF_SERVICE, EMERGENCY_ONLY, POWER_OFF
  • Duplex mode: UNKNOWN, FDD, TDD
  • Roaming indicator
  • Operator name, short name and numeric id
  • Network selection mode
For historical reasons this class is not declared as final; however, it should be treated as though it were final.

Summary

Constants
static Int

Duplex mode for the phone is frequency-division duplexing.

static Int

Duplex mode for the phone is time-division duplexing.

static Int

Duplex mode for the phone is unknown.

static Int

The phone is registered and locked.

static Int

Normal operation condition, the phone is registered with an operator either in home network or in roaming.

static Int

Phone is not registered with any operator, the phone can be currently searching a new operator to register to, or not searching to registration at all, or registration is denied, or radio signal is not available.

static Int

Radio of telephony is explicitly powered off.

static Int

Unknown ID.

Inherited constants
Public constructors

Empty constructor

Copy constructors

Construct a ServiceState object from the given parcel.

Public methods
open Int

open Boolean
equals(other: Any?)

open Int

Get the CDMA NID (Network Identification Number), a number uniquely identifying a network within a wireless system.

open Int

Get the CDMA SID (System Identification Number), a number uniquely identifying a wireless system.

open IntArray!

Get an array of cell bandwidths (kHz) for the current serving cells

open Int

Get the channel number of the current primary serving cell, or -1 if unknown

open Int

Get the current duplex mode

open Boolean

Get current network selection mode.

open MutableList<NetworkRegistrationInfo!>

Get all of the available network registration info.

open String!

Get current registered operator name in long alphanumeric format.

open String!

Get current registered operator name in short alphanumeric format.

open String!

Get current registered operator numeric id.

open Boolean

Get current roaming indicator of phone.

open Int

Get current voice service state

open Int

open Boolean

This indicates whether the device is searching for service.

open Boolean

Get whether device is connected to a non-terrestrial network.

open Unit

open Unit
setOperatorName(longName: String!, shortName: String!, numeric: String!)

open Unit
setRoaming(roaming: Boolean)

open Unit
setState(state: Int)

open Unit

open Unit

open String

open Unit
writeToParcel(out: Parcel, flags: Int)

Protected methods
open Unit

Properties
static Parcelable.Creator<ServiceState!>

Constants

DUPLEX_MODE_FDD

Added in API level 28
static val DUPLEX_MODE_FDD: Int

Duplex mode for the phone is frequency-division duplexing.

Value: 1

DUPLEX_MODE_TDD

Added in API level 28
static val DUPLEX_MODE_TDD: Int

Duplex mode for the phone is time-division duplexing.

Value: 2

DUPLEX_MODE_UNKNOWN

Added in API level 28
static val DUPLEX_MODE_UNKNOWN: Int

Duplex mode for the phone is unknown.

Value: 0

STATE_EMERGENCY_ONLY

Added in API level 1
static val STATE_EMERGENCY_ONLY: Int

The phone is registered and locked. Only emergency numbers are allowed. {@more}

Value: 2

STATE_IN_SERVICE

Added in API level 1
static val STATE_IN_SERVICE: Int

Normal operation condition, the phone is registered with an operator either in home network or in roaming.

Value: 0

STATE_OUT_OF_SERVICE

Added in API level 1
static val STATE_OUT_OF_SERVICE: Int

Phone is not registered with any operator, the phone can be currently searching a new operator to register to, or not searching to registration at all, or registration is denied, or radio signal is not available.

Value: 1

STATE_POWER_OFF

Added in API level 1
static val STATE_POWER_OFF: Int

Radio of telephony is explicitly powered off.

Value: 3

UNKNOWN_ID

Added in API level 28
static val UNKNOWN_ID: Int

Unknown ID. Could be returned by getCdmaNetworkId() or getCdmaSystemId()

Value: -1

Public constructors

ServiceState

Added in API level 1
ServiceState()

Empty constructor

ServiceState

Added in API level 1
ServiceState(s: ServiceState!)

Copy constructors

Parameters
s ServiceState!: Source service state

ServiceState

Added in API level 1
ServiceState(in: Parcel!)

Deprecated: The constructor takes parcel should not be public at the beginning. Use ServiceState() instead.

Construct a ServiceState object from the given parcel.

Public methods

describeContents

Added in API level 1
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 1
open fun equals(other: Any?): Boolean
Parameters
obj the reference object with which to compare.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getCdmaNetworkId

Added in API level 28
open fun getCdmaNetworkId(): Int

Get the CDMA NID (Network Identification Number), a number uniquely identifying a network within a wireless system. (Defined in 3GPP2 C.S0023 3.4.8)

Require at least android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION. Otherwise return UNKNOWN_ID.
Requires android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION

Return
Int The CDMA NID or UNKNOWN_ID if not available.

getCdmaSystemId

Added in API level 28
open fun getCdmaSystemId(): Int

Get the CDMA SID (System Identification Number), a number uniquely identifying a wireless system. (Defined in 3GPP2 C.S0023 3.4.8)

Require at least android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION. Otherwise return UNKNOWN_ID.
Requires android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION

Return
Int The CDMA SID or UNKNOWN_ID if not available.

getCellBandwidths

Added in API level 28
open fun getCellBandwidths(): IntArray!

Get an array of cell bandwidths (kHz) for the current serving cells

Return
IntArray! Current serving cell bandwidths

getChannelNumber

Added in API level 28
open fun getChannelNumber(): Int

Get the channel number of the current primary serving cell, or -1 if unknown

This is NRARFCN for NR, EARFCN for LTE, UARFCN for UMTS, and ARFCN for GSM.

Return
Int Channel number of primary serving cell

getDuplexMode

Added in API level 28
open fun getDuplexMode(): Int

Get the current duplex mode

Return
Int Current DuplexMode for the phone Value is android.telephony.ServiceState#DUPLEX_MODE_UNKNOWN, android.telephony.ServiceState#DUPLEX_MODE_FDD, or android.telephony.ServiceState#DUPLEX_MODE_TDD

getIsManualSelection

Added in API level 1
open fun getIsManualSelection(): Boolean

Get current network selection mode.

Return
Boolean true if manual mode, false if automatic mode

getNetworkRegistrationInfoList

Added in API level 30
open fun getNetworkRegistrationInfoList(): MutableList<NetworkRegistrationInfo!>

Get all of the available network registration info.

Return
MutableList<NetworkRegistrationInfo!> List of NetworkRegistrationInfo This value cannot be null.

getOperatorAlphaLong

Added in API level 1
open fun getOperatorAlphaLong(): String!

Get current registered operator name in long alphanumeric format. In GSM/UMTS, long format can be up to 16 characters long. In CDMA, returns the ERI text, if set. Otherwise, returns the ONS. Require at least android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION. Otherwise return null if the caller does not hold neither android.Manifest.permission#ACCESS_FINE_LOCATION nor android.Manifest.permission#ACCESS_COARSE_LOCATION.
Requires android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION

Return
String! long name of operator, null if unregistered or unknown

getOperatorAlphaShort

Added in API level 1
open fun getOperatorAlphaShort(): String!

Get current registered operator name in short alphanumeric format. In GSM/UMTS, short format can be up to 8 characters long. Require at least android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION. Otherwise return null if the caller does not hold neither android.Manifest.permission#ACCESS_FINE_LOCATION nor android.Manifest.permission#ACCESS_COARSE_LOCATION.
Requires android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION

Return
String! short name of operator, null if unregistered or unknown

getOperatorNumeric

Added in API level 1
open fun getOperatorNumeric(): String!

Get current registered operator numeric id. In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit network code. Require at least android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION. Otherwise return null if the caller does not hold neither android.Manifest.permission#ACCESS_FINE_LOCATION nor android.Manifest.permission#ACCESS_COARSE_LOCATION.
Requires android.Manifest.permission#ACCESS_FINE_LOCATION or android.Manifest.permission#ACCESS_COARSE_LOCATION

Return
String! numeric format of operator, null if unregistered or unknown

getState

Added in API level 1
open fun getState(): Int

Get current voice service state

hashCode

Added in API level 1
open fun hashCode(): Int
Return
Int a hash code value for this object.

isSearching

Added in API level 30
open fun isSearching(): Boolean

This indicates whether the device is searching for service. This API reports the modem searching status for AccessNetworkConstants#TRANSPORT_TYPE_WWAN (cellular) service in either NetworkRegistrationInfo#DOMAIN_CS or NetworkRegistrationInfo#DOMAIN_PS. This API will not report searching status for AccessNetworkConstants#TRANSPORT_TYPE_WLAN.

Return
Boolean true whenever the modem is searching for service.

isUsingNonTerrestrialNetwork

Added in API level 35
open fun isUsingNonTerrestrialNetwork(): Boolean

Get whether device is connected to a non-terrestrial network.

Return
Boolean true if device is connected to a non-terrestrial network else false.

setIsManualSelection

Added in API level 1
open fun setIsManualSelection(isManual: Boolean): Unit

setOperatorName

Added in API level 1
open fun setOperatorName(
    longName: String!,
    shortName: String!,
    numeric: String!
): Unit

setRoaming

Added in API level 1
open fun setRoaming(roaming: Boolean): Unit

setState

Added in API level 1
open fun setState(state: Int): Unit

setStateOff

Added in API level 1
open fun setStateOff(): Unit

setStateOutOfService

Added in API level 1
open fun setStateOutOfService(): Unit

toString

Added in API level 1
open fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 1
open fun writeToParcel(
    out: Parcel,
    flags: Int
): Unit
Parameters
dest The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Protected methods

copyFrom

Added in API level 1
protected open fun copyFrom(s: ServiceState!): Unit

Properties

CREATOR

Added in API level 1
static val CREATOR: Parcelable.Creator<ServiceState!>