在這個程序中我使用了一些常量,比如WIFI_STATIC_IP改變爲靜態IP。wifi_static_ip棄用的Api-17 4.2
當我創建file.apk並安裝在Android API-10或版本2.3.3似乎工作。它連接到分配的無線和固定IP。
另一個平板電腦Api-15或4.0.3版連接到wifi,但不更改IP。但是它表明這些常量在API-17或更高版本中已棄用。
我不明白,因爲它只適用於API-11版本而不適用於API-15,或者我不明白什麼是棄用。
Settings.System.putInt(cr, Settings.System.ACCELEROMETER_ROTATION, 0); Settings.System.putInt(cr, Settings.System.WIFI_USE_STATIC_IP, 1); Settings.System.putString(cr, Settings.System.WIFI_STATIC_IP, "192.168.1.209"); Settings.System.putString(cr, Settings.System.WIFI_STATIC_NETMASK, "255.255.255.0"); Settings.System.putString(cr, Settings.System.WIFI_STATIC_GATEWAY, "192.168.1.1"); Settings.System.putString(cr, Settings.System.WIFI_STATIC_DNS1, "192.168.1.1");
而且在manifest.xml文件我表示這個版本:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
感謝您的快速回復,您也是對的。但我仍然有一些未解答的問題。 我不明白它爲什麼在版本2.3.3中起作用,而不是在4.1.2中,如果常量在4.2或更高版本中已棄用 –
正如你提到我,如果我明白它被棄用的是什麼,那麼實際上我看起來是WifiManager, '不知道如何使用它來把固定的IP地址[鏈接](http://developer.android.com/reference/android/net/wifi/WifiManager.html) –
只是檢查:你'android.permission。 WRITE_SETTINGS'設置爲您的應用程序。除此之外,請檢查catlog是否有來自系統的錯誤跡象。 – chr