I have an app installed on the raspberry pi 3 using AndroidThings [preview 0.4]. IN the app code I make a connection to the wifi. I then do a call to the wifiManager to get the connection info.
WifiInfo info = wifiManager.getConnectionInfo();
String ssid = info.getSSID();
String state = info.getSupplicantState().name();
int ipAddress = info.getIpAddress();
String ip = String.format("%d.%d.%d.%d", (ipAddress & 0xff), (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff));
boolean enabled = wifiManager.isWifiEnabled();
String result = "wifi: " + ssid + " ip: " + ip + " " + state + " enabled:" + enabled;
The result prints out as 'wifi: "milt-att" ip: 0.0.0.0 COMPLETED enabled:true
If I restart the app several times I will eventually get a legitimate ip address. If the SSID is not valid or the passkey to the SSID is incorrect, it tells me that it is DISCONNECTED. Why do I not get a valid ip address once connected?