'Android'에 해당되는 글 2건

  1. 2010.10.07 android : 네트워크 상태 보기 1
  2. 2010.06.30 상속받은 View 를 xml 레이아웃에 추가하기 4
안드로이드에서 네트워크를 이용하는 어플인 경우, 현재 네트워크 상태를 다음과 같이 체크 할 수 있다.




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

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 권한을 설정해야 함.
:
XML 레이아웃에 본인이 작성한 View 를 넣고자 할 때,


 
AnotherView 클래스에서는 생성자를 오버로딩 하면 된다.



여기서 만약, 파라미터 2개짜리인 생성자를 오버로딩 하지 않으면 안 좋은 일이 일어난다.
궁금하다면 직접 해 보시라 ~

: