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

Construct a ServiceState object from the given parcel.

Copy constructors

Public methods
open Int

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

open Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

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

Returns a hash code value for the object.

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

Returns a string representation of the object.

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

Flatten this object in to a Parcel.

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(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.

ServiceState

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

Copy constructors

Parameters
s ServiceState!: Source service state

Public methods

describeContents

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

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel,int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
Value is either 0 or

equals

Added in API level 1
open fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

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 UNKNOWN_ID as CDMA is no longer supported.

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 UNKNOWN_ID as CDMA is no longer supported.

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 one of the following:

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

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
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

Returns a string representation of the object.

Return
String a string representation of the object.

writeToParcel

Added in API level 1
open fun writeToParcel(
    out: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

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 the following:

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!>