NetworkInfo(示例,出错代码)
来源:互联网 发布:派爱充值系统源码 编辑:程序博客网 时间:2024/05/22 11:38
NetworkInfo(示例,出错代码)
出处:Android API 作者:Android API 阅读:1529次
android.net
类 NetworkInfo
java.lang.Object android.net.NetworkInfo
- 所有已实现的接口:
- Parcelable
public class NetworkInfo
- extends Object
- implements Parcelable
Describes the status of a network interface of a given type (currently either Mobile or Wifi).
static class
NetworkInfo.DetailedState
The fine-grained state of a network connection.
static class
NetworkInfo.State
Coarse-grained network state.
Parcelable.Creator<T>
static Parcelable.Creator<NetworkInfo>
CREATOR
Implement the Parcelable interface.
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
NetworkInfo(int type)
已过时。
int
describeContents()
Implement the Parcelable interface
NetworkInfo.DetailedState
getDetailedState()
Reports the current fine-grained state of the network.
String
getExtraInfo()
Report the extra information about the network state, if any was provided by the lower networking layers., if one is available.
String
getReason()
Report the reason an attempt to establish connectivity failed, if one is available.
NetworkInfo.State
getState()
Reports the current coarse-grained state of the network.
int
getSubtype()
Return a network-type-specific integer describing the subtype of the network.
String
getSubtypeName()
Return a human-readable name describing the subtype of the network.
int
getType()
Reports the type of network (currently mobile or Wi-Fi) to which the info in this object pertains.
String
getTypeName()
Return a human-readable name describe the type of the network, for example "WIFI" or "MOBILE".
boolean
isAvailable()
Indicates whether network connectivity is possible.
boolean
isConnected()
Indicates whether network connectivity exists and it is possible to establish connections and pass data.
boolean
isConnectedOrConnecting()
Indicates whether network connectivity exists or is in the process of being established.
boolean
isFailover()
Indicates whether the current attempt to connect to the network resulted from the ConnectivityManager trying to fail over to this network following a disconnect from another network.
boolean
isRoaming()
Indicates whether the device is currently roaming on this network.
void
setFailover(boolean isFailover)
Set the failover boolean.
void
setIsAvailable(boolean isAvailable)
Sets if the network is available, ie, if the connectivity is possible.
String
toString()
Returns a string containing a concise, human-readable description of this object.
void
writeToParcel(Parcel dest, int flags)
Implement the Parcelable interface.
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
CREATOR
public static final Parcelable.Creator<NetworkInfo> CREATOR
- Implement the Parcelable interface.
NetworkInfo
public NetworkInfo(int type)
- 已过时。
- 参数:
type
- network type
getType
public int getType()
- Reports the type of network (currently mobile or Wi-Fi) to which the info in this object pertains.
- 返回:
- the network type
getSubtype
public int getSubtype()
- Return a network-type-specific integer describing the subtype of the network.
- 返回:
- the network subtype
getTypeName
public String getTypeName()
- Return a human-readable name describe the type of the network, for example "WIFI" or "MOBILE".
- 返回:
- the name of the network type
getSubtypeName
public String getSubtypeName()
- Return a human-readable name describing the subtype of the network.
- 返回:
- the name of the network subtype
isConnectedOrConnecting
public boolean isConnectedOrConnecting()
- Indicates whether network connectivity exists or is in the process of being established. This is good for applications that need to do anything related to the network other than read or write data. For the latter, call isConnected() instead, which guarantees that the network is fully usable.
- 返回:
true
if network connectivity exists or is in the process of being established,false
otherwise.
isConnected
public boolean isConnected()
- Indicates whether network connectivity exists and it is possible to establish connections and pass data.
- 返回:
true
if network connectivity exists,false
otherwise.
isAvailable
public boolean isAvailable()
- Indicates whether network connectivity is possible. A network is unavailable when a persistent or semi-persistent condition prevents the possibility of connecting to that network. Examples include
- The device is out of the coverage area for any network of this type.
- The device is on a network other than the home network (i.e., roaming), and data roaming has been disabled.
- The device's radio is turned off, e.g., because airplane mode is enabled.
- 返回:
true
if the network is available,false
otherwise
setIsAvailable
public void setIsAvailable(boolean isAvailable)
- Sets if the network is available, ie, if the connectivity is possible.
- 参数:
isAvailable
- the new availability value.
isFailover
public boolean isFailover()
- Indicates whether the current attempt to connect to the network resulted from the ConnectivityManager trying to fail over to this network following a disconnect from another network.
- 返回:
true
if this is a failover attempt,false
otherwise.
setFailover
public void setFailover(boolean isFailover)
- Set the failover boolean.
- 参数:
isFailover
-true
to mark the current connection attempt as a failover.
isRoaming
public boolean isRoaming()
- Indicates whether the device is currently roaming on this network. When
true
, it suggests that use of data on this network may incur extra costs. - 返回:
true
if roaming is in effect,false
otherwise.
getState
public NetworkInfo.State getState()
- Reports the current coarse-grained state of the network.
- 返回:
- the coarse-grained state
getDetailedState
public NetworkInfo.DetailedState getDetailedState()
- Reports the current fine-grained state of the network.
- 返回:
- the fine-grained state
getReason
public String getReason()
- Report the reason an attempt to establish connectivity failed, if one is available.
- 返回:
- the reason for failure, or null if not available
getExtraInfo
public String getExtraInfo()
- Report the extra information about the network state, if any was provided by the lower networking layers., if one is available.
- 返回:
- the extra information, or null if not available
toString
public String toString()
- 从类
Object
复制的描述 - Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation simply concatenates the class name, the '@' sign and a hexadecimal representation of the object's Object.hashCode(), that is, it is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
- 覆盖:
- 类
Object
中的toString
- 返回:
- a printable representation of this object.
describeContents
public int describeContents()
- Implement the Parcelable interface
- 指定者:
- 接口
Parcelable
中的describeContents
- 返回:
- a bitmask indicating the set of special object types marshalled by the Parcelable.
writeToParcel
public void writeToParcel(Parcel dest, int flags)
- Implement the Parcelable interface.
- 指定者:
- 接口
Parcelable
中的writeToParcel
- 参数:
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
0 0
- NetworkInfo(示例,出错代码)
- AlarmManager(示例,出错代码)
- AbstractTableModel(示例,出错代码)
- PrintWriter(示例,出错代码)
- Field(示例,出错代码)
- Calendar(示例,出错代码)
- SimpleDateFormat(示例,出错代码)
- TransformerFactory(示例,出错代码)
- SocketChannel(示例,出错代码)
- DefaultTableModel(示例,出错代码)
- Toolkit(示例,出错代码)
- NetworkInfo
- SharedPreferences.Editor(示例,出错代码)
- MFC之AfxMessageBox(示例,出错代码)
- boost的MulticastSocket(示例,出错代码)
- Android学习笔记十二:Calendar(示例、出错代码、参数)
- Androin学习笔记二十五:InetAddress(示例,出错代码)
- Android学习笔记二十八:String(示例,出错代码)
- 继搜索和移动,拉里 佩奇正在将Google带入“第三个世代”
- [第3天] 程序的控制结构——循环嵌套例题05
- 本地YUM源配置Redhat Enterprise 5.9
- .Net程序员玩转Android开发---(1)环境搭建
- POJ1062Dijkstra
- NetworkInfo(示例,出错代码)
- ubuntu 14.04 amd 64 的ftp server
- 第10周项目2-M$pszi$y是嘛意思?
- android客户端与服务端交互的三种方式
- hdu5092 Seam Carving(dp 打印路径)
- hdu5095 模拟
- QMainWindow与QWidget和QDialog设置布局的不同之处
- hdu 4059 The Boss on Mars(容斥)
- 分享一个链接