안드로이드에서 네트워크를 이용하는 어플인 경우, 현재 네트워크 상태를 다음과 같이 체크 할 수 있다.




* 다음은 안드로이드 레퍼런스 사이트에서 일부 발췌.

public boolean isAvailable ()

Since: API Level 1

Indicates whether network connectivity is possible. A network is unavailable when a persistent or semi-persistent condition prevents the possibility of connecting to that network. Examples include

  • The device is out of the coverage area for any network of this type.
  • The device is on a network other than the home network (i.e., roaming), and data roaming has been disabled.
  • The device's radio is turned off, e.g., because airplane mode is enabled.
Returns
  • true if the network is available, false otherwise

public boolean isConnected ()

Since: API Level 1

Indicates whether network connectivity exists and it is possible to establish connections and pass data.

Returns
  • true if network connectivity exists, false otherwise.



* Manifest 에서 ACCESS_NETWORK_STATE 권한을 설정해야 함.
: