Most visited

Recently visited

Added in API level 1

ServiceState

public class ServiceState
extends Object implements Parcelable

java.lang.Object
   ↳ android.telephony.ServiceState


包含电话状态和服务相关信息。 返回的ServiceState中包含以下电话信息:

Summary

Constants

int STATE_EMERGENCY_ONLY

手机已注册并锁定。 只允许紧急号码。

int STATE_IN_SERVICE

正常操作条件下,手机在家庭网络或漫游中向运营商注册。

int STATE_OUT_OF_SERVICE

电话未向任何运营商注册,电话当前可能正在搜索要注册的新运营商,或者根本不搜索注册,或注册被拒绝,或无线电信号不可用。

int STATE_POWER_OFF

电话无线电明确关闭。

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<ServiceState> CREATOR

Public constructors

ServiceState()

空构造函数

ServiceState(ServiceState s)

复制构造函数

ServiceState(Parcel in)

从给定的宗地构造一个ServiceState对象。

Public methods

int describeContents()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。

boolean equals(Object o)

指示其他某个对象是否“等于”这一个。

boolean getIsManualSelection()

获取当前的网络选择模式。

String getOperatorAlphaLong()

以长字母数字格式获取当前注册的运营商名称。

String getOperatorAlphaShort()

以简短的字母数字格式获取当前注册的操作员姓名。

String getOperatorNumeric()

获取当前注册的运营商数字ID。

boolean getRoaming()

获取手机的当前漫游指示符(注意:不只是从TS 27.007 7.2解码)

int getState()

获取当前语音服务状态

int hashCode()

返回对象的哈希码值。

void setIsManualSelection(boolean isManual)
void setOperatorName(String longName, String shortName, String numeric)
void setRoaming(boolean roaming)
void setState(int state)
void setStateOff()
void setStateOutOfService()
String toString()

返回对象的字符串表示形式。

void writeToParcel(Parcel out, int flags)

将此对象平铺到一个包裹中。

Protected methods

void copyFrom(ServiceState s)

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

STATE_EMERGENCY_ONLY

Added in API level 1
int STATE_EMERGENCY_ONLY

手机已注册并锁定。 只允许紧急号码。

常量值:2(0x00000002)

STATE_IN_SERVICE

Added in API level 1
int STATE_IN_SERVICE

正常操作条件下,手机在家庭网络或漫游中向运营商注册。

常量值:0(0x00000000)

STATE_OUT_OF_SERVICE

Added in API level 1
int STATE_OUT_OF_SERVICE

电话未向任何运营商注册,电话当前可能正在搜索要注册的新运营商,或者根本不搜索注册,或注册被拒绝,或无线电信号不可用。

常数值:1(0x00000001)

STATE_POWER_OFF

Added in API level 1
int STATE_POWER_OFF

电话无线电明确关闭。

常量值:3(0x00000003)

Fields

CREATOR

Added in API level 1
Creator<ServiceState> CREATOR

Public constructors

ServiceState

Added in API level 1
ServiceState ()

空构造函数

ServiceState

Added in API level 1
ServiceState (ServiceState s)

复制构造函数

Parameters
s ServiceState: Source service state

ServiceState

Added in API level 1
ServiceState (Parcel in)

从给定的宗地构造一个ServiceState对象。

Parameters
in Parcel

Public methods

describeContents

Added in API level 1
int describeContents ()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。 例如,如果对象在writeToParcel(Parcel, int)的输出中包含writeToParcel(Parcel, int) ,则此方法的返回值必须包含CONTENTS_FILE_DESCRIPTOR位。

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

equals

Added in API level 1
boolean equals (Object o)

指示其他某个对象是否“等于”这一个。

equals方法在非空对象引用上实现等价关系:

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

equals方法Object实现了对象上最可能的等价关系; 也就是说,对于任何非空参考值xy ,当且仅当xy引用同一对象( x == y的值为true )时,此方法返回true

请注意,无论何时重写此方法,通常都需要重写 hashCode方法,以便维护 hashCode方法的常规协定,该方法声明相等对象必须具有相同的哈希码。

Parameters
o Object: the reference object with which to compare.
Returns
boolean true if this object is the same as the obj argument; false otherwise.

getIsManualSelection

Added in API level 1
boolean getIsManualSelection ()

获取当前的网络选择模式。

Returns
boolean true if manual mode, false if automatic mode

getOperatorAlphaLong

Added in API level 1
String getOperatorAlphaLong ()

以长字母数字格式获取当前注册的运营商名称。 在GSM / UMTS中,长格式最长可以有16个字符。 在CDMA中,返回ERI文本,如果设置。 否则,返回ONS。

Returns
String long name of operator, null if unregistered or unknown

getOperatorAlphaShort

Added in API level 1
String getOperatorAlphaShort ()

以简短的字母数字格式获取当前注册的操作员姓名。 在GSM / UMTS中,短格式可以长达8个字符。

Returns
String short name of operator, null if unregistered or unknown

getOperatorNumeric

Added in API level 1
String getOperatorNumeric ()

获取当前注册的运营商数字ID。 在GSM / UMTS中,数字格式是3位国家代码加2或3位网络代码。

Returns
String numeric format of operator, null if unregistered or unknown

getRoaming

Added in API level 1
boolean getRoaming ()

获取手机的当前漫游指示符(注意:不只是从TS 27.007 7.2解码)

Returns
boolean true if TS 27.007 7.2 roaming is true and ONS is different from SPN

getState

Added in API level 1
int getState ()

获取当前语音服务状态

Returns
int

hashCode

Added in API level 1
int hashCode ()

返回对象的哈希码值。 为了散列表的好处而支持此方法,例如由HashMap提供的HashMap

hashCode的总合同是:

  • 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(Object) 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(java.lang.Object) 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.

尽可能合理实用,类Object定义的hashCode方法确实为不同的对象返回不同的整数。 (这通常通过将对象的内部地址转换为整数来实现,但Java TM编程语言不需要此实现技术。)

Returns
int a hash code value for this object.

setIsManualSelection

Added in API level 1
void setIsManualSelection (boolean isManual)

Parameters
isManual boolean

setOperatorName

Added in API level 1
void setOperatorName (String longName, 
                String shortName, 
                String numeric)

Parameters
longName String
shortName String
numeric String

setRoaming

Added in API level 1
void setRoaming (boolean roaming)

Parameters
roaming boolean

setState

Added in API level 1
void setState (int state)

Parameters
state int

setStateOff

Added in API level 1
void setStateOff ()

setStateOutOfService

Added in API level 1
void setStateOutOfService ()

toString

Added in API level 1
String toString ()

返回对象的字符串表示形式。 通常, toString方法返回一个“文本表示”该对象的字符串。 结果应该是一个简洁但内容丰富的表述,对于一个人来说很容易阅读。 建议所有子类重写此方法。

ObjecttoString方法返回一个字符串,其中包含对象为实例的类的名称,符号字符“ @ ”以及对象的哈希代码的无符号十六进制表示形式。 换句话说,这个方法返回一个字符串,其值等于:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

Added in API level 1
void writeToParcel (Parcel out, 
                int flags)

将此对象平铺到一个包裹中。

Parameters
out Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

Protected methods

copyFrom

Added in API level 1
void copyFrom (ServiceState s)

Parameters
s ServiceState

Hooray!