2014.08.18 17:01

안드로이드 네트워크 상태 확인

boolean isNetworkConnectionAvailable() {
	ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
	NetworkInfo info = cm.getActiveNetworkInfo();
	if (info == null)
		return false;
	State network = info.getState();
	return (network == NetworkInfo.State.CONNECTED || network == NetworkInfo.State.CONNECTING);
}


[출처] How to check the network availability?

Trackback 0 Comment 0