Android
android.net
public abstract class

android.net.NetworkStateTracker

java.lang.Object
android.os.Handler
android.net.NetworkStateTracker

Each subclass of this class keeps track of the state of connectivity of a network interface. All state information for a network should be kept in a Tracker class. This superclass manages the network-type-independent aspects of network state.

Known Direct Subclasses

Summary

Constants

      Value  
int  EVENT_NOTIFICATION_CHANGED  arg1: 1 to show, 0 to hide arg2: ID of the notification obj: Notification (if showing)   0x00000003 
int  EVENT_SCAN_RESULTS_AVAILABLE    0x00000002 
int  EVENT_STATE_CHANGED    0x00000001 

Fields

protected      Context  mContext   
protected      NetworkInfo  mNetworkInfo   
protected      Handler  mTarget   

Public Constructors

            NetworkStateTracker(Context context, Handler target, NetworkType networkType)

Public Methods

abstract          String[]  getNameServers()
Return the list of DNS servers associated with this network.
          NetworkInfo  getNetworkInfo()
          void  interpretScanResultsAvailable()
Interprets scan results.
abstract          boolean  isAvailable()
Returns an indication of whether this network is available for connections.
abstract          boolean  reconnect()
Reenable connectivity to a network after a teardown().
          void  setDetailedState(NetworkInfo.DetailedState state, String reason, String extraInfo)
Record the detailed state of a network, and if it is a change from the previous state, send a notification to any listeners.
          void  setDetailedState(NetworkInfo.DetailedState state)
Record the detailed state of a network, and if it is a change from the previous state, send a notification to any listeners.
abstract          boolean  setRadio(boolean turnOn)
Turn the wireless radio off for a network.
abstract          void  startMonitoring()
abstract          int  startUsingNetworkFeature(String feature)
Tells the underlying networking system that the caller wants to begin using the named feature.
abstract          int  stopUsingNetworkFeature(String feature)
Tells the underlying networking system that the caller is finished using the named feature.
abstract          boolean  teardown()
Disable connectivity to a network

Protected Methods

      static    String[]  getNameServerList(String[] propertyNames)
Return the IP addresses of the DNS servers available for this network interface.
          void  sendScanResultsAvailable()
Send a notification that the results of a scan for network access points has completed, and results are available.
Methods inherited from class android.os.Handler
Methods inherited from class java.lang.Object

Details

Constants

public static final int EVENT_NOTIFICATION_CHANGED

arg1: 1 to show, 0 to hide arg2: ID of the notification obj: Notification (if showing)
Constant Value: 3 (0x00000003)

public static final int EVENT_SCAN_RESULTS_AVAILABLE

Constant Value: 2 (0x00000002)

public static final int EVENT_STATE_CHANGED

Constant Value: 1 (0x00000001)

Fields

protected Context mContext

protected NetworkInfo mNetworkInfo

protected Handler mTarget

Public Constructors

public NetworkStateTracker(Context context, Handler target, NetworkType networkType)

Public Methods

public abstract String[] getNameServers()

Return the list of DNS servers associated with this network.

Returns

  • a list of the IP addresses of the DNS servers available for the network.

public NetworkInfo getNetworkInfo()

public void interpretScanResultsAvailable()

Interprets scan results. This will be called at a safe time for processing, and from a safe thread.

public abstract boolean isAvailable()

Returns an indication of whether this network is available for connections. A value of false means that some quasi-permanent condition prevents connectivity to this network.

public abstract boolean reconnect()

Reenable connectivity to a network after a teardown().

public void setDetailedState(NetworkInfo.DetailedState state, String reason, String extraInfo)

Record the detailed state of a network, and if it is a change from the previous state, send a notification to any listeners.

Parameters

state the new @{code DetailedState}
reason a String indicating a reason for the state change, if one was supplied. May be null.
extraInfo optional String providing extra information about the state change

public void setDetailedState(NetworkInfo.DetailedState state)

Record the detailed state of a network, and if it is a change from the previous state, send a notification to any listeners.

Parameters

state the new @{code DetailedState}

public abstract boolean setRadio(boolean turnOn)

Turn the wireless radio off for a network.

Parameters

turnOn true to turn the radio on, false

public abstract void startMonitoring()

public abstract int startUsingNetworkFeature(String feature)

Tells the underlying networking system that the caller wants to begin using the named feature. The interpretation of feature is completely up to each networking implementation.

Parameters

feature the name of the feature to be used

Returns

  • an integer value representing the outcome of the request. The interpretation of this value is specific to each networking implementation+feature combination, except that the value -1 always indicates failure.

public abstract int stopUsingNetworkFeature(String feature)

Tells the underlying networking system that the caller is finished using the named feature. The interpretation of feature is completely up to each networking implementation.

Parameters

feature the name of the feature that is no longer needed.

Returns

  • an integer value representing the outcome of the request. The interpretation of this value is specific to each networking implementation+feature combination, except that the value -1 always indicates failure.

public abstract boolean teardown()

Disable connectivity to a network

Returns

  • true if a teardown occurred, false if the teardown did not occur.

Protected Methods

protected static String[] getNameServerList(String[] propertyNames)

Return the IP addresses of the DNS servers available for this network interface.

Parameters

propertyNames the names of the system properties whose values give the IP addresses. Properties with no values are skipped.

Returns

  • an array of Strings containing the IP addresses of the DNS servers, in dot-notation. This may have fewer non-null entries than the list of names passed in, since some of the passed-in names may have empty values.

protected void sendScanResultsAvailable()

Send a notification that the results of a scan for network access points has completed, and results are available.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56