Code example for WifiManager

Methods: getConnectionInfogetDhcpInfo

0
        return null; 
    } 
 
    private JSONObject getDHCPJson() {
        wifiManger = (WifiManager) cordova.getActivity().getSystemService(Context.WIFI_SERVICE);
        DhcpInfo dhcpInfo = wifiManger.getDhcpInfo();
        WifiInfo wifiInfo = wifiManger.getConnectionInfo();
        JSONObject dhcpJson = new JSONObject();
        try { 
            dhcpJson.put("staticIp", intToIp(dhcpInfo.ipAddress));
            dhcpJson.put("wifiAddress", intToIp(wifiInfo.getIpAddress()));
            dhcpJson.put("netmask", intToIp(dhcpInfo.netmask));
            dhcpJson.put("gateway", intToIp(dhcpInfo.gateway));
            dhcpJson.put("dns1", intToIp(dhcpInfo.dns1));
            dhcpJson.put("dns2", intToIp(dhcpInfo.dns2));
            dhcpJson.put("serverAddress", intToIp(dhcpInfo.serverAddress));
            dhcpJson.put("mac", String.valueOf(wifiInfo.getMacAddress()));
            dhcpJson.put("ssid", wifiInfo.getSSID());
            int useStatic = Settings.System.getInt(cordova.getActivity().getContentResolver(), Settings.System.WIFI_USE_STATIC_IP);
            dhcpJson.put("use_static_ip", useStatic == 1 ? "Static" : "Auto");
        } catch (JSONException ex) {