3
我試圖使用下面的代碼來設置設備使用靜態IP加入一個沒有DHCP的AP,但它似乎不適用於任何特定的AP。該設備仍嘗試獲取因缺少DHCP而無法訪問的IP地址。Android:如何使用靜態IP連接到接入點?
Settings.System.setString(getContentResolver(), "wifi_static_ip", "192.168.1.99);
Settings.System.setInt(getContentResolver(), "wifi_use_static_ip", 1);
WifiConfiguration wc = new WifiConfiguration();
wc.SSID = "SSID";
wc.preSharedKey = "key";
wc.status = WifiConfiguration.Status.ENABLED;
int netId = wifiManager.addNetwork(wc);
wifiManager.enableNetwork(netId, true);
我試圖使用此線程提供的方法,但它不起作用。 How to configue a static IP address, netmask, gateway programmatically on Android 3.x or 4.x