Now i can say: "I caught it"
I spent many days by looking for better, cleaner and for 100% working solution how actual (now i guess currently only one solution) solution with reflection is. But without result.
So i tried again to use mentioned solution with reflection here:
and suprisingly it works! And now i know what i was missing. So everyone who tried this solution on device with API
greater than 10 (sice Honeycomb) make sure you called:
wifiManager.saveConfiguration();
it's not enough to call only
wifiManager.updateNetwork(wifiConfiguration);
bacause changes (also made via reflection) won't be permanently saved to specific WifiConfiguration.
So now it works as expected and now a little summary:
Setting static IP address for Android 1.x and 2.x :
Android 1.x and 2.x doesn't provide solution for setting static ip address per SSID (only for actual connected network) so simple working solution is to use ContentResolver and write data to System Settings via:
Settings.System.putInt(resolver, "wifi_use_static_ip", 1); // enabling static ip
Settings.System.putInt(resolver, "wifi_use_static_ip", 0); // enabling DHCP
Setting static IP address for Android 3.x and 4.x:
Since Android 3.x it's possible to set static ip address per SSID hence solution for lower versions of Android OS will not working.
Currently there is no API
for this purpose so solution with reflection linked above is only one that actually works.
Notes:
Don't forget to change setGateway()
for Android 3.x (also mentioned in origin thread)
Finally since if someone want to have application for setting static ip adress for Android 3.x and 4.x proper method takes netmask prefix as int and not full netmask so here is list of available netmasks with their prefixes.
Hope it helps.