public class NetworkStatusManager
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
NetworkStatusManager.State |
| Modifier and Type | Field and Description |
|---|---|
static int |
NETWORK_CLASS_2G
2G网络
|
static java.lang.String |
NETWORK_CLASS_2G_NAME |
static int |
NETWORK_CLASS_3G
3G网络
|
static java.lang.String |
NETWORK_CLASS_3G_NAME |
static int |
NETWORK_CLASS_4G
4G网络
|
static java.lang.String |
NETWORK_CLASS_4G_NAME |
static int |
NETWORK_CLASS_UNKNOWN
未知网络类别
|
static java.lang.String |
NETWORK_CLASS_UNKNOWN_NAME |
static int |
NETWORK_CLASS_WIFI
WIFI网络
|
static java.lang.String |
NETWORK_CLASS_WIFI_NAME |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkIsWifi(android.content.Context context) |
static NetworkStatusManager |
getInstance() |
android.net.NetworkInfo |
getNetworkInfo()
Return the NetworkInfo associated with the most recent connectivity event.
|
int |
getNetworkType()
2G/3G/4G/WIFI
|
java.lang.String |
getNetworkTypeName() |
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.
|
static void |
init(android.content.Context context) |
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.
|
boolean |
isWifi() |
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.
|
public static final int NETWORK_CLASS_UNKNOWN
public static final java.lang.String NETWORK_CLASS_UNKNOWN_NAME
public static final int NETWORK_CLASS_2G
public static final java.lang.String NETWORK_CLASS_2G_NAME
public static final int NETWORK_CLASS_3G
public static final java.lang.String NETWORK_CLASS_3G_NAME
public static final int NETWORK_CLASS_4G
public static final java.lang.String NETWORK_CLASS_4G_NAME
public static final int NETWORK_CLASS_WIFI
public static final java.lang.String NETWORK_CLASS_WIFI_NAME
public static void init(android.content.Context context)
public static NetworkStatusManager getInstance()
public static boolean checkIsWifi(android.content.Context context)
public int getNetworkType()
public void startListening(android.content.Context context)
context - public void stopListening()
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 fail over attempt, false otherwise.public java.lang.String getReason()
null otherwise.public boolean isWifi()
public java.lang.String getNetworkTypeName()