content: package com.akansh.fileserversuit;
  
  import android.content.Context;
  import android.net.wifi.WifiManager;
  
  import java.lang.reflect.Method;
  
  public class WifiApManager {
      private final WifiManager mWifiManager;
  
      public WifiApManager(Context context) {
          mWifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
      }
  
      /*the following method is for getting the wifi hotspot state*/
  
      public WIFI_AP_STATE getWifiApState() {
          try {
              Method method = mWifiManager.getClass().getMethod("getWifiApState");
  
              int tmp = ((Integer) method.invoke(mWifiManager));
  
              // Fix for Android 4
              if (tmp > 10) {
                  tmp = tmp - 10;
              }
              return WIFI_AP_STATE.class.getEnumConstants()[tmp];
          } catch (Exception e) {
              return WIFI_AP_STATE.WIFI_AP_STATE_FAILED;
          }
      }
  
      /**
       * Return whether Wi-Fi Hotspot is enabled or disabled.
       *
       * @return {@code true} if Wi-Fi AP is enabled
       * @see #getWifiApState()
       */
      public boolean isWifiApEnabled() {
          return getWifiApState() == WIFI_AP_STATE.WIFI_AP_STATE_ENABLED;
      }
  
      public enum WIFI_AP_STATE {
          WIFI_AP_STATE_DISABLING,
          WIFI_AP_STATE_DISABLED,
          WIFI_AP_STATE_ENABLING,
          WIFI_AP_STATE_ENABLED,
          WIFI_AP_STATE_FAILED
      }
  
  }
  