-
public class NetworkUtils网络管理工具类
-
-
Method Summary
Modifier and Type Method Description static voidopenNetSetting(Activity activity)打开网络设置界面 static NetworkInfo.StategetCurrentNetworkState(Context context)获取当前网络的状态 static booleanisConnectedByState(Context context)判断当前网络是否已经连接 static booleanisConnectingByState(Context context)判断当前网络是否正在连接 static booleanisDisconnectedByState(Context context)判断当前网络是否已经断开 static booleanisDisconnectingByState(Context context)判断当前网络是否正在断开 static booleanisSuspendedByState(Context context)判断当前网络是否已经暂停 static intgetWifiState(Context context)获取Wifi的状态,需要ACCESS_WIFI_STATE权限 static booleanisWifiOpen(Context context)判断Wifi是否打开,需要ACCESS_WIFI_STATE权限 static booleansetWifi(Context context, boolean enable)设置Wifi,需要CHANGE_WIFI_STATE权限 static StringgetIpAddress()获取本机IP地址 static WifiInfogetWifiConnectionInfo(Context context)获取wifi连接信息 static StringgetProxy(Context context)获得Proxy地址 -
-
Method Detail
-
openNetSetting
static void openNetSetting(Activity activity)
打开网络设置界面
- Parameters:
activity- Activity
-
getCurrentNetworkState
static NetworkInfo.State getCurrentNetworkState(Context context)
获取当前网络的状态
- Parameters:
context- 上下文
-
isConnectedByState
static boolean isConnectedByState(Context context)
判断当前网络是否已经连接
- Parameters:
context- 上下文
-
isConnectingByState
static boolean isConnectingByState(Context context)
判断当前网络是否正在连接
- Parameters:
context- 上下文
-
isDisconnectedByState
static boolean isDisconnectedByState(Context context)
判断当前网络是否已经断开
- Parameters:
context- 上下文
-
isDisconnectingByState
static boolean isDisconnectingByState(Context context)
判断当前网络是否正在断开
- Parameters:
context- 上下文
-
isSuspendedByState
static boolean isSuspendedByState(Context context)
判断当前网络是否已经暂停
- Parameters:
context- 上下文
-
getWifiState
static int getWifiState(Context context)
获取Wifi的状态,需要ACCESS_WIFI_STATE权限
- Parameters:
context- 上下文
-
isWifiOpen
static boolean isWifiOpen(Context context)
判断Wifi是否打开,需要ACCESS_WIFI_STATE权限
- Parameters:
context- 上下文
-
setWifi
static boolean setWifi(Context context, boolean enable)
设置Wifi,需要CHANGE_WIFI_STATE权限
- Parameters:
context- 上下文enable- wifi状态
-
getIpAddress
static String getIpAddress()
获取本机IP地址
-
getWifiConnectionInfo
static WifiInfo getWifiConnectionInfo(Context context)
获取wifi连接信息
-
-
-
-