How do you plan that the device operates on Wi-Fi access points?



  • How can Java Java know that the phone is on the access point?

    I need to know if Wi-Fi's phone is being distributed or connected to it.

    Here's the Wi-Fi verification code:

    public boolean isWiFiOn() {
        final WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        if(wifi != null)
            switch(wifi.getWifiState()) {
                case(WifiManager.WIFI_STATE_DISABLED):
                case(WifiManager.WIFI_STATE_DISABLING):
                    return false;
                default:
                    return true;
            }
        return false;
    }
    

    But this code is coming back. falseif the phone's on the access point.

    How do you know if he's giving Wi-Fi?



  • We can't officially find out, but Androids and Androids can do a lot of things with hac:
    There's a hidden one. @hide Method getWifiApState:

    Method method = wifiManager.getClass().getDeclaredMethod("getWifiApState");
    method.setAccessible(true);
    int actualState = (Integer) method.invoke(wifiManager, (Object[]) null);
    

    Next. actualState Compare with such constants:

    public static int WIFI_AP_STATE_DISABLING = 10; //выключается
    public static int WIFI_AP_STATE_DISABLED = 11;  //выключен
    public static int WIFI_AP_STATE_ENABLING = 12;  //включается
    public static int WIFI_AP_STATE_ENABLED = 13;   //включен
    public static int WIFI_AP_STATE_FAILED = 14;    //сломалсо
    

    UPD: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/net/wifi/WifiManager.java#WifiManager.getWifiApState%28%29 by reference method:




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2