Again stuck in the same problem.
I found around that we can set static system settings as follows:
System.putString(getContentResolver(), android.provider.Settings.System.WIFI_USE_STATIC_IP, "1"); // to define it use static ip's System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_IP,"192.168.1.15"); System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_NETMASK,"255.255.255.0"); System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_DNS1,"192.168.1.1"); System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_GATEWAY,"192.168.1.1");
But without success!
I don’t understand when to set these settings?
Do I have to do this before creating a wifi configuration or after saving a Wi-Fi configuration or even before or after activating it?
However, I tried all possible cases on my part, and when I check the Android WiFi settings, I see that it is still on DHCP.
The previous question, i.e. How to configure a static IP address, netmask, gateway programmatically on Android 3.x or 4.x , completely ruined my Android device and now it can’t switch ON its WiFi anymore.
I also tried a static IP address on my HTC phone and did not succeed, its always in DHCP mode!
Do I need to call the reconnect command? If so, how?