Code example for ConnectivityManager

Methods: getNetworkInfo

0
  } 
   
  public static boolean hasDataConnection(final Context context) {
    final ConnectivityManager connMgr = 
        (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    final NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    if (wifi != null && wifi.isAvailable()) {
      return true; 
    }  
    if (mobile != null && mobile.isAvailable()) {
      return true; 
    } 
    return false;     
  } 
   
  public Status justWriteFile() { 
    Status status = null;
    final CountStats countStats = new CountStats();
    final Bundle bundle = new Bundle();