本文整理汇总了Java中android.net.NetworkInfo.DetailedState方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkInfo.DetailedState方法的具体用法?Java NetworkInfo.DetailedState怎么用?Java NetworkInfo.DetailedState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.NetworkInfo
的用法示例。
在下文中一共展示了NetworkInfo.DetailedState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newInstance
import android.net.NetworkInfo; //导入方法依赖的package包/类
public static NetworkInfo newInstance(
NetworkInfo.DetailedState detailedState, int type, int subType, boolean isAvailable, boolean isConnected,
boolean isRoaming) {
NetworkInfo networkInfo = org.robolectric.shadows.ShadowNetworkInfo.newInstance(
detailedState, type, subType, isAvailable, isConnected);
ShadowNetworkInfo info = (ShadowNetworkInfo) shadowOf(networkInfo);
info.setRoaming(isRoaming);
return networkInfo;
}
示例2: setNetworkInfo
import android.net.NetworkInfo; //导入方法依赖的package包/类
public static void setNetworkInfo(Context context, boolean isConnected, boolean isRoaming, boolean isWifi) {
ShadowConnectivityManager manager =
shadowOf((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
NetworkInfo.DetailedState detailedState =
isConnected ? NetworkInfo.DetailedState.CONNECTED : NetworkInfo.DetailedState.DISCONNECTED;
int type = isConnected ? (isWifi ? ConnectivityManager.TYPE_WIFI : ConnectivityManager.TYPE_MOBILE) : -1;
NetworkInfo networkInfo =
ShadowNetworkInfo.newInstance(detailedState, type, 0, isConnected, isConnected, isRoaming);
manager.setActiveNetworkInfo(networkInfo);
}
示例3: getWifiName
import android.net.NetworkInfo; //导入方法依赖的package包/类
public String getWifiName(Context context) {
WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (manager.isWifiEnabled()) {
WifiInfo wifiInfo = manager.getConnectionInfo();
if (wifiInfo != null) {
NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
return wifiInfo.getSSID();
}
}
}
return null;
}
示例4: getDetailedState
import android.net.NetworkInfo; //导入方法依赖的package包/类
public NetworkInfo.DetailedState getDetailedState() {
return detailedState;
}
示例5: getDetailedState
import android.net.NetworkInfo; //导入方法依赖的package包/类
/** @see NetworkInfo#getDetailedState() */
public NetworkInfo.DetailedState getDetailedState() {
return detailedState;
}