I tried to use the following code to set the device to use static ip to join an AP without DHCP, but it doesn't seem to work for any particular AP. The device still tries to obtain an IP address which it fails to since lack of DHCP.
Settings.System.setString(getContentResolver(), "wifi_static_ip", "192.168.1.99);
Settings.System.setInt(getContentResolver(), "wifi_use_static_ip", 1);
WifiConfiguration wc = new WifiConfiguration();
wc.SSID = "SSID";
wc.preSharedKey = "key";
wc.status = WifiConfiguration.Status.ENABLED;
int netId = wifiManager.addNetwork(wc);
wifiManager.enableNetwork(netId, true);
I tried to use the method this thread provided, but it doesn't work. How to configue a static IP address, netmask, gateway programmatically on Android 3.x or 4.x