本文整理汇总了Java中android.net.NetworkInfo.getDetailedState方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkInfo.getDetailedState方法的具体用法?Java NetworkInfo.getDetailedState怎么用?Java NetworkInfo.getDetailedState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.NetworkInfo
的用法示例。
在下文中一共展示了NetworkInfo.getDetailedState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isConnectivityFailure
import android.net.NetworkInfo; //导入方法依赖的package包/类
private boolean isConnectivityFailure() {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS);
return networkInfo == null || networkInfo.getDetailedState() == NetworkInfo.DetailedState.FAILED;
}
示例2: getWifiConnectivityState
import android.net.NetworkInfo; //导入方法依赖的package包/类
public static DetailedState getWifiConnectivityState(Context context) {
NetworkInfo networkInfo = getNetworkInfo(context, 1);
return networkInfo == null ? DetailedState.FAILED : networkInfo.getDetailedState();
}
示例3: onReceive
import android.net.NetworkInfo; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null)
return;
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);
updateWiFiState(wifiState);
} else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
DetailedState state = info.getDetailedState();
String descr = null;
switch (state) {
case CONNECTING:
descr = mActivity.getString(R.string.txt_net_status_connecting);
break;
case OBTAINING_IPADDR:
descr = mActivity.getString(R.string.txt_net_status_obtainingip);
break;
case CONNECTED:
// String name =
// intent.getStringExtra(WifiManager.EXTRA_BSSID);
String name = getWiFiManager().getConnectionInfo().getSSID();
descr = mActivity.getString(R.string.txt_net_status_connected_to, name);
break;
case FAILED:
descr = mActivity.getString(R.string.txt_net_status_failed);
break;
case DISCONNECTING:
descr = mActivity.getString(R.string.txt_net_status_disconnecting);
break;
case DISCONNECTED:
descr = mActivity.getString(R.string.txt_net_status_disconnected);
break;
}
if (descr != null) {
mSetting.descr = descr; // update description
mSetting.updateView();
}
}
}