Code example for NetworkInfo

Methods: getSubtypegetType

    try { 
      // Try to see network information to determine the ideal thread pool size. 
      ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
      if(networkInfo != null) {
        final int type = networkInfo.getType();
        switch(type) {
            // Connection subtype will return integer respective for 1G, 2G, 3G 
            // For 3G connections and better, we should use up to half the max pool size. 
            if(networkInfo.getSubtype() >= 3) {
              return maxThreads / 2;
            // For all other cases, just use one thread. EDGE/2G is slow pretty much everywhere. 
            else { 
              return 1; 
          // For WIFI, use the entire available thread pool 
          case CONNECTION_TYPE_WIFI:
            return maxThreads;
Connect your IDE to all the code out there  Get Codota for Java