Im working on one project and there should be a functionality for setting static IP address (DNS, Netmask, Gateway) for Wifi
if user want it.
My initial and actual solution is an usage of android.provider.Settings.System
class that allows this feature but this solution works successfully only for Android 2.x devices.
It's nice, definitely i'm not on totally zero but it would be nice to get it work also for higher versions of Android OS. It don't know exactly why it doesn't work.
If i use this simple method for checking actual status:
public static final boolean hasStaticIp(Context c) {
try {
return Settings.System.getInt(c.getContentResolver(),
Settings.System.WIFI_USE_STATIC_IP) == 1;
}
catch (SettingNotFoundException e) {
Log.i(TAG, "Settings not found (" + e.geMessage() + ")");
return false;
}
}
it returns true for both Android 2.x and also Android 4.x but in second case, changes are definitely not reflected in Wifi
I found this a little hardcoded solution but it didn't work as expected.
Is there anyone that faced against same problem?
I'll be glad for any working solution and also for rooted devices (maybe some command in linux) since it's easy to check status of whether cellphone is rooted or not.
Thanks in advance.