Getting WiFi Direct IP address of my device

android, ip, java, wifi-direct

Solution

send out the peer's local ip address (starting with 192.168.x.x) to the group owner. After this "handshake", which doesn't really take time, it's all good to go. Did not find any other way to get the peer's ip addresses, the only information provided by GroupListener/PeerListener/... is the mac address.

Problem

I am trying to get the ip address of my device but all in vain and no success. I've tried ``` 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 and no other method is working too..Help !!

Original source

Related problems