Do the Wifi-Direct Ip_address and Ip address given by any WIFI router to the smart-phone same? I am below code to get my IP address.
public String getP2PIpAddr() {
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_P2P_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ip = wifiInfo.getIpAddress();
String ipString = String.format(
"%d.%d.%d.%d",
(ip & 0xff),
(ip >> 8 & 0xff),
(ip >> 16 & 0xff),
(ip >> 24 & 0xff));
return ipString;
}
but its giving me 0.0.0.0 when i am not connected to any wifi router.But it is returning me IP address given by router to phone but not the wifi-direct IPAddress..
Please Help...
Thanks In advance..