java.lang.Objectcom.netmera.mobile.NetworkConnectivityListener
public class NetworkConnectivityListener
A wrapper for a broadcast receiver that provides network connectivity state information, independent of network type (mobile, Wi-Fi, etc.).
Nested Class Summary | |
---|---|
static class |
NetworkConnectivityListener.State
|
Constructor Summary | |
---|---|
NetworkConnectivityListener()
Create a new NetworkConnectivityListener. |
Method Summary | |
---|---|
android.net.NetworkInfo |
getNetworkInfo()
Return the NetworkInfo associated with the most recent connectivity event. |
android.net.NetworkInfo |
getOtherNetworkInfo()
If the most recent connectivity event was a DISCONNECT, return any information supplied in the broadcast about an alternate network that might be available. |
java.lang.String |
getReason()
An optional reason for the connectivity state change may have been supplied. |
NetworkConnectivityListener.State |
getState()
|
boolean |
isFailOver()
Returns true if the most recent event was for an attempt to switch over to a new network following loss of connectivity on another network. |
void |
registerHandler(android.os.Handler target,
int what)
This methods registers a Handler to be called back onto with the specified what code when the network connectivity state changes. |
void |
startListening(android.content.Context context)
This method starts listening for network connectivity state changes. |
void |
stopListening()
This method stops this class from listening for network changes. |
void |
unregisterHandler(android.os.Handler target)
This methods unregisters the specified Handler. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NetworkConnectivityListener()
Method Detail |
---|
public void startListening(android.content.Context context)
context
- public void stopListening()
public void registerHandler(android.os.Handler target, int what)
target
- The target handler.what
- The what code to be used when posting a message to the
handler.public void unregisterHandler(android.os.Handler target)
target
- public NetworkConnectivityListener.State getState()
public android.net.NetworkInfo getNetworkInfo()
NetworkInfo
for the network that had the most recent
connectivity event.public android.net.NetworkInfo getOtherNetworkInfo()
public boolean isFailOver()
true
if this was a failover attempt, false
otherwise.public java.lang.String getReason()
null
otherwise.