BLOG ARTICLE 와이파이 | 1 ARTICLE FOUND

  1. 2012.02.24 [Android] 안드로이드 모바일, 와이파이, 인터넷 상태 체크


 

 
    private Boolean isNetWork(){
   
    ConnectivityManager manager = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
 
    boolean isMobileAvailable = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isAvailable();
   boolean isMobileConnect = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting();
   boolean isWifiAvailable = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isAvailable();
   boolean isWifiConnect = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
           
   if ((isWifiAvailable && isWifiConnect) || (isMobileAvailable && isMobileConnect)){
    return true;
    }else{
    return false;
    }
    }   

퍼미션- 두가지 다 필요한건지 확인은 안해밨음
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 

YOUR COMMENT IS THE CRITICAL SUCCESS FACTOR FOR THE QUALITY OF BLOG POST