Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to configure a static IP address, netmask, gateway programmatically on Android 3.x or 4.x
    text
    copied!<p>I have checked in Stack Overflow question <em><a href="https://stackoverflow.com/questions/2922455">API for configuring static IP addresses in an Android application</a></em>.</p> <p>It works until Android 2.3. However, there is no luck on a higher API level. For example, I put the setting</p> <pre><code>android.provider.Settings.System.putString(getContentResolver(), android.provider.Settings.System.WIFI_USE_STATIC_IP, "1"); android.provider.Settings.System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_IP, "192.168.0.100"); android.provider.Settings.System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_NETMASK, "255.255.255.0"); android.provider.Settings.System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_DNS1, "192.168.0.254"); android.provider.Settings.System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_GATEWAY, "192.168.0.254"); </code></pre> <p>But I go back to check by:</p> <pre><code>Setting --&gt; Wi-Fi --&gt; Long Press Access Point SSID --&gt; Modify Network --&gt; check Show advanced options </code></pre> <p>The <code>IP Settings</code> field is still stated <code>DHCP</code> but not <code>Static</code>. </p> <p>It is true that I can use <code>android.provider.Settings.System.getString()</code> to get back what I set. It prove that the setting is saved somewhere but the system just ignore it. </p> <p>The system uses the setting other than <code>android.provider.Settings.System</code> on Android 3.x and 4.x as the setting is set per Access Point SSID. Can I modify the setting on one SSID just like how it works on Android 2.3?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload