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
Public Constructors
Public Methods
getNameServerList,
getNameServers,
getNetworkInfo,
interpretScanResultsAvailable,
isAvailable,
reconnect,
sendScanResultsAvailable,
setDetailedState,
setDetailedState,
setRadio,
startMonitoring,
startUsingNetworkFeature,
stopUsingNetworkFeature,
teardown
dispatchMessage,
dump,
getLooper,
handleMessage,
hasMessages,
hasMessages,
obtainMessage,
obtainMessage,
obtainMessage,
obtainMessage,
obtainMessage,
post,
postAtFrontOfQueue,
postAtTime,
postAtTime,
postDelayed,
removeCallbacks,
removeCallbacks,
removeCallbacksAndMessages,
removeMessages,
removeMessages,
sendEmptyMessage,
sendEmptyMessageAtTime,
sendEmptyMessageDelayed,
sendMessage,
sendMessageAtFrontOfQueue,
sendMessageAtTime,
sendMessageDelayed,
toString
|
|
|
|
|
void |
dispatchMessage(Message msg) |
|
|
final |
|
|
void |
dump(Printer pw, String prefix) |
|
|
final |
|
|
Looper |
getLooper() |
|
|
|
|
|
void |
handleMessage(Message msg) |
|
|
final |
|
|
boolean |
hasMessages(int what) |
|
|
final |
|
|
boolean |
hasMessages(int what, Object object) |
|
|
final |
|
|
Message |
obtainMessage(int what, Object obj) |
|
|
final |
|
|
Message |
obtainMessage(int what, int arg1, int arg2, Object obj) |
|
|
final |
|
|
Message |
obtainMessage(int what, int arg1, int arg2) |
|
|
final |
|
|
Message |
obtainMessage() |
|
|
final |
|
|
Message |
obtainMessage(int what) |
|
|
final |
|
|
boolean |
post(Runnable r) |
|
|
final |
|
|
boolean |
postAtFrontOfQueue(Runnable r) |
|
|
final |
|
|
boolean |
postAtTime(Runnable r, Object token, long uptimeMillis) |
|
|
final |
|
|
boolean |
postAtTime(Runnable r, long uptimeMillis) |
|
|
final |
|
|
boolean |
postDelayed(Runnable r, long delayMillis) |
|
|
final |
|
|
void |
removeCallbacks(Runnable r, Object token) |
|
|
final |
|
|
void |
removeCallbacks(Runnable r) |
|
|
final |
|
|
void |
removeCallbacksAndMessages(Object token) |
|
|
final |
|
|
void |
removeMessages(int what) |
|
|
final |
|
|
void |
removeMessages(int what, Object object) |
|
|
final |
|
|
boolean |
sendEmptyMessage(int what) |
|
|
final |
|
|
boolean |
sendEmptyMessageAtTime(int what, long uptimeMillis) |
|
|
final |
|
|
boolean |
sendEmptyMessageDelayed(int what, long delayMillis) |
|
|
final |
|
|
boolean |
sendMessage(Message msg) |
|
|
final |
|
|
boolean |
sendMessageAtFrontOfQueue(Message msg) |
|
|
|
|
|
boolean |
sendMessageAtTime(Message msg, long uptimeMillis) |
|
|
final |
|
|
boolean |
sendMessageDelayed(Message msg, long delayMillis) |
|
|
|
|
|
String |
toString() |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
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.