android - WiFi direct Ip address -


do wifi-direct ip_address , ip address given wifi router smart-phone same? below code 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 giving me 0.0.0.0 when not connected wifi router.but returning me ip address given router phone not wifi-direct ipaddress..

please help...

thanks in advance..

no ip addresses not same. making mistakes here, getsystemservice(wifi_p2p_service) returns wifip2pmanager not wifimanager.

secondly use wifimanager.getconnectioninfo() when connected normal wifi network i.e. via router or hotspot. not ip when connected via wifidirect not normal wifi network. thus, reason getting ip 0.0.0.0.

now main question ips in wifidirect. if groupowner have fixed go_ip = 192.168.43.1. so, in onconnectioninfoavailable or ongroupinfoavailable, can info.isgroupowner() , if not groupowner other system is, hence ip go_ip, system can communicate go using go_ip

now if go wants communicate client, can ip using networkinterfaces. refer how client ip.

i think should solve problem.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -