本文整理匯總了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();
}
}
}