public static boolean isWifiConnected(Context context){
  ConnectivityManager connectivityManager=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo networkInfo=connectivityManager.getActiveNetworkInfo();
  return networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI;
}

public static boolean isWifiConnected ( Context context ) { ConnectivityManager connectivityManager = ( ConnectivityManager ) context . getSystemService ( Context . CONNECTIVITY_SERVICE ) ; NetworkInfo networkInfo = connectivityManager . getActiveNetworkInfo ( ) ; return networkInfo != null && networkInfo . getType ( ) == ConnectivityManager . TYPE_WIFI ; }
this method requires the caller to hold the permission access_network_state .
