Build 1.0_r1(from source)

android.net
Class NetworkInfo

java.lang.Object
  extended by android.net.NetworkInfo
All Implemented Interfaces:
Parcelable

public class NetworkInfo
extends Object
implements Parcelable

Describes the status of a network interface of a given type (currently either Mobile or Wifi).


Nested Class Summary
static class NetworkInfo.DetailedState
          The fine-grained state of a network connection.
static class NetworkInfo.State
          Coarse-grained network state.
 
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.Creator<T>
 
Field Summary
static Parcelable.Creator<NetworkInfo> CREATOR
          Implement the Parcelable interface
 
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
 
Constructor Summary
NetworkInfo(int type)
           
 
Method Summary
 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 getType()
          Reports the type of network (currently mobile or Wi-Fi) to which the info in this object pertains.
 String getTypeName()
           
 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.
(package private)  void setDetailedState(NetworkInfo.DetailedState detailedState, String reason, String extraInfo)
          Sets the fine-grained state of the network.
 void setFailover(boolean isFailover)
          
 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 the receiver.
 void writeToParcel(Parcel dest, int flags)
          Implement the Parcelable interface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CREATOR

public static final Parcelable.Creator<NetworkInfo> CREATOR
Implement the Parcelable interface

Constructor Detail

NetworkInfo

public NetworkInfo(int type)
Method Detail

getType

public int getType()
Reports the type of network (currently mobile or Wi-Fi) to which the info in this object pertains.

Returns:
the network type

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.

Returns:
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.

Returns:
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

Returns:
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.

Parameters:
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.

Returns:
true if this is a failover attempt, false otherwise.

setFailover

public void setFailover(boolean isFailover)


getState

public NetworkInfo.State getState()
Reports the current coarse-grained state of the network.

Returns:
the coarse-grained state

getDetailedState

public NetworkInfo.DetailedState getDetailedState()
Reports the current fine-grained state of the network.

Returns:
the fine-grained state

setDetailedState

void setDetailedState(NetworkInfo.DetailedState detailedState,
                      String reason,
                      String extraInfo)
Sets the fine-grained state of the network.

Parameters:
detailedState - the NetworkInfo.DetailedState.
reason - a String indicating the reason for the state change, if one was supplied. May be null.
extraInfo - an optional String providing addditional network state information passed up from the lower networking layers.

getReason

public String getReason()
Report the reason an attempt to establish connectivity failed, if one is available.

Returns:
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.

Returns:
the extra information, or null if not available

toString

public String toString()
Description copied from class: Object
Returns a string containing a concise, human-readable description of the receiver.

Overrides:
toString in class Object
Returns:
String a printable representation for the receiver.

getTypeName

public String getTypeName()

describeContents

public int describeContents()
Implement the Parcelable interface

Specified by:
describeContents in interface Parcelable
Returns:
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

Specified by:
writeToParcel in interface Parcelable
Parameters:
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.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature