Android
android.net
public class

android.net.MobileDataStateTracker

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

Track the state of mobile data connectivity. This is done by receiving broadcast intents from the Phone process whenever the state of data connectivity changes.

Summary

Constants inherited from class android.net.NetworkStateTracker
Fields inherited from class android.net.NetworkStateTracker

Public Constructors

            MobileDataStateTracker(Context context, Handler target)
Create a new MobileDataStateTracker

Public Methods

          void  addPrivateRoutes()
          String[]  getNameServers()
Return the IP addresses of the DNS servers available for the mobile data network interface.
          boolean  isAvailable()
Report whether data connectivity is possible.
          boolean  reconnect()
Re-enable mobile data connectivity after a teardown().
          void  removeDefaultRoute()
          void  removePrivateRoutes()
          void  restoreDefaultRoute()
          boolean  setRadio(boolean turnOn)
Turn on or off the mobile radio.
          void  startMonitoring()
Begin monitoring mobile data connectivity.
          int  startUsingNetworkFeature(String feature)
Tells the phone sub-system that the caller wants to begin using the named feature.
          int  stopUsingNetworkFeature(String feature)
Tells the phone sub-system that the caller is finished is finished using the named feature.
          boolean  teardown()
Tear down mobile data connectivity, i.e., disable the ability to create mobile data connections.
          String  toString()
Returns a string containing a concise, human-readable description of the receiver.
Methods inherited from class android.net.NetworkStateTracker
Methods inherited from class android.os.Handler
Methods inherited from class java.lang.Object

Details

Public Constructors

public MobileDataStateTracker(Context context, Handler target)

Create a new MobileDataStateTracker

Parameters

context the application context of the caller
target a message handler for getting callbacks about state changes

Public Methods

public void addPrivateRoutes()

public String[] getNameServers()

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

Returns

  • a list of DNS addresses, with no holes.

public boolean isAvailable()

Report whether data connectivity is possible.

public boolean reconnect()

Re-enable mobile data connectivity after a teardown().

public void removeDefaultRoute()

public void removePrivateRoutes()

public void restoreDefaultRoute()

public boolean setRadio(boolean turnOn)

Turn on or off the mobile radio. No connectivity will be possible while the radio is off. The operation is a no-op if the radio is already in the desired state.

Parameters

turnOn true if the radio should be turned on, false if

public void startMonitoring()

Begin monitoring mobile data connectivity.

public int startUsingNetworkFeature(String feature)

Tells the phone sub-system that the caller wants to begin using the named feature. The only supported feature at this time is Phone.FEATURE_ENABLE_MMS, which allows an application to specify that it wants to send and/or receive MMS data.

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 feature-specific. specific, except that the value -1 always indicates failure. For Phone.FEATURE_ENABLE_MMS, the other possible return values are
    • Phone.APN_ALREADY_ACTIVE
    • Phone.APN_REQUEST_STARTED
    • Phone.APN_TYPE_NOT_AVAILABLE
    • Phone.APN_REQUEST_FAILED

public int stopUsingNetworkFeature(String feature)

Tells the phone sub-system that the caller is finished is finished using the named feature. The only supported feature at this time is Phone.FEATURE_ENABLE_MMS, which allows an application to specify that it wants to send and/or receive MMS data.

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 feature-specific, except that the value -1 always indicates failure.

public boolean teardown()

Tear down mobile data connectivity, i.e., disable the ability to create mobile data connections.

Returns

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

public String toString()

Returns a string containing a concise, human-readable description of the receiver.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48