当前位置: 首页>>代码示例>>Java>>正文


Java State.DISCONNECTING属性代码示例

本文整理汇总了Java中android.net.NetworkInfo.State.DISCONNECTING属性的典型用法代码示例。如果您正苦于以下问题:Java State.DISCONNECTING属性的具体用法?Java State.DISCONNECTING怎么用?Java State.DISCONNECTING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.net.NetworkInfo.State的用法示例。


在下文中一共展示了State.DISCONNECTING属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDataConnectionState

public static int getDataConnectionState(Context context) {
    if (!isSimInstalled(context)) {
        return NETWORK_UTILS_CONNECTION_STATE_DISCONNECTED;
    }

    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    for (NetworkInfo info : manager.getAllNetworkInfo()) {
        if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            if (info.getState() == State.CONNECTED) {
                return NETWORK_UTILS_CONNECTION_STATE_CONNECTED;
            } else if (info.getState() == State.DISCONNECTED) {
                return NETWORK_UTILS_CONNECTION_STATE_DISCONNECTED;
            } else if (info.getState() == State.CONNECTING) {
                return NETWORK_UTILS_CONNECTION_STATE_CONNECTING;
            } else if (info.getState() == State.DISCONNECTING) {
                return NETWORK_UTILS_CONNECTION_STATE_DISCONNECTED;
            } else if (info.getState() == State.SUSPENDED) {
                return NETWORK_UTILS_CONNECTION_STATE_SUSPENDED;
            } else if (info.getState() == State.UNKNOWN) {
                return NETWORK_UTILS_CONNECTION_STATE_UNKNOWN;
            }
        }
    }

    return NETWORK_UTILS_CONNECTION_STATE_DISCONNECTED;
}
 
开发者ID:ashank,项目名称:Office-365-SDK-for-Android,代码行数:26,代码来源:NetworkUtils.java

示例2: onReceive

public void onReceive(Context c, Intent intent) {
	NetworkInfo wifiNetworkInfo = (NetworkInfo) intent
			.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
	Log.v(TAG, "mWifiNetworkInfo: " + wifiNetworkInfo.toString());

	if (wifiNetworkInfo.getState() == State.CONNECTED) {
		log.setText("Connected to: "
				+ wifiManager.getConnectionInfo().getSSID());
		if (wifiManager != null
				&& wifiManager.getConnectionInfo() != null
				&& wifiManager.getConnectionInfo().getSSID() != null
				&& !wifiManager.getConnectionInfo().getSSID()
						.equals(wifiSSID)) {
			Log.v(TAG, wifiManager.getConnectionInfo().getSSID());

			refreshWifi();					
		}
	} else if (wifiNetworkInfo.getState() == State.CONNECTING) {
		log.setText("Connecting...");
	} else if (wifiNetworkInfo.getState() == State.DISCONNECTING) {
		log.setText("Disconnecting...");
	} else if (wifiNetworkInfo.getState() == State.DISCONNECTED) {
		log.setText("Disconnected");
	}

}
 
开发者ID:takyonxxx,项目名称:Gopro-Manager-Android,代码行数:26,代码来源:GoproActivity.java

示例3: getWifiStatus

public static String getWifiStatus(Context context) {
	String wifiStatus = "";
	ConnectivityManager conMan = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);
	State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
			.getState();

	WifiManager wifiManager = (WifiManager) context
			.getSystemService(Context.WIFI_SERVICE);
	WifiInfo wifiInfo = wifiManager.getConnectionInfo();
	String ssid = wifiInfo.getSSID();

	if (wifi == State.CONNECTED) {
		wifiStatus = "无线网络已连接, " + "SSID: " + ssid;
	} else if (wifi == State.CONNECTING) {
		wifiStatus = "无线网络正在连接, " + "SSID: " + ssid;
	} else if (wifi == State.DISCONNECTED) {
		wifiStatus = "无线网络已断开";
	} else if (wifi == State.DISCONNECTING) {
		wifiStatus = "无线网络正在断开, " + "SSID: " + ssid;
	} else if (wifi == State.SUSPENDED) {
		wifiStatus = "无线网络挂起";
	} else if (wifi == State.UNKNOWN) {
		wifiStatus = "无线网络未连接";
	}
	return wifiStatus;
}
 
开发者ID:leleliu008,项目名称:Newton_for_Android_AS,代码行数:27,代码来源:Helper.java

示例4: setNetworkConnection

public void setNetworkConnection(Context context) {
	this.currentContext = context;

	ConnectivityManager connectivityManager = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);

	NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

	if (networkInfo == null) {
		VoiceApi.makeToastShort(currentContext, "无网络连接");
		return;
	}
	switch (networkInfo.getType()) {
	case ConnectivityManager.TYPE_WIFI:
		VoiceApi.makeToastShort(context, "WIFI Connection");
		break;
	case ConnectivityManager.TYPE_MOBILE:
		VoiceApi.makeToastShort(context, "MOBILE Connection");
		break;
	default:
		VoiceApi.makeToastShort(context, "Unknown Connection");
		break;
	}

	boolean available = networkInfo.isAvailable();
	if (available) {
		VoiceApi.makeToastShort(context,
				"Current Connectivity is Available");
	} else {
		VoiceApi.makeToastShort(context,
				"Current Connectivity is not Available");
	}

	State state = connectivityManager.getNetworkInfo(
			ConnectivityManager.TYPE_MOBILE).getState();
	if (State.CONNECTED == state) {
		VoiceApi.makeToastShort(context, "GPRS Connected");
	} else if (State.CONNECTING == state) {
		VoiceApi.makeToastShort(context, "GPRS Connecting");
	} else if (State.DISCONNECTING == state) {
		VoiceApi.makeToastShort(context, "GPRS Disconnecting");
	} else if (State.DISCONNECTED == state) {
		VoiceApi.makeToastShort(context, "GPRS Disconnected");
	} else {
		VoiceApi.makeToastShort(context, "Other GPRS State");
	}

	state = connectivityManager.getNetworkInfo(
			ConnectivityManager.TYPE_WIFI).getState();
	if (State.CONNECTED == state) {
		VoiceApi.makeToastShort(context, "WIFI Connected");
	} else if (State.CONNECTING == state) {
		VoiceApi.makeToastShort(context, "WIFI Connecting");
	} else if (State.DISCONNECTING == state) {
		VoiceApi.makeToastShort(context, "WIFI Disconnecting");
	} else if (State.DISCONNECTED == state) {
		VoiceApi.makeToastShort(context, "WIFI Disconnected");
	} else {
		VoiceApi.makeToastShort(context, "Other WIFI State");
	}

	context.startActivity(new Intent(
			android.provider.Settings.ACTION_WIRELESS_SETTINGS));
}
 
开发者ID:3c,项目名称:TestRecord,代码行数:64,代码来源:VoiceApi.java


注:本文中的android.net.NetworkInfo.State.DISCONNECTING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。