title: Android: How to connect to an Access Point using static IP?
body: <p>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.</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>I tried to use the method this thread provided, but it doesn't work.
  <a href="https://stackoverflow.com/questions/10278461/how-to-configue-static-ip-netmask-gateway-programmatically-on-android-3-x-or-4"><a href="https://stackoverflow.com/questions/10278461/how-to-configue-static-ip-netmask-gateway-programmatically-on-android-3-x-or-4">How to configue a static IP address, netmask, gateway programmatically on Android 3.x or 4.x</a></a></p>