How to know the connected WiFi is Walled Gardened (Captive Portal)?

You can get the networkcapabilities from the network and check if it has the NET_CAPABILITY_CAPTIVE_PORTAL :

API 23

ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
Network activeNetwork=connectivityManager.getActiveNetwork();
NetworkCapabilities networkCapabilities=connectivityManager.getNetworkCapabilities(activeNetwork);
if(networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL)){
        //DO SOMETHING
}

http://developer.android.com/intl/es/reference/android/net/NetworkCapabilities.html

NetworkCapabilities was introduced in API 21, so you can do this for

API >= 21

ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
Network[] activeNetworks=connectivityManager.getAllNetworks();
for(Network network:activeNetworks){
    if(connectivityManager.getNetworkInfo(network).isConnected()){
        NetworkCapabilities networkCapabilities=connectivityManager.getNetworkCapabilities(network);
        if(networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL)){
           //DO SOMETHING
        }
        break;
    }
}