سؤال

i m trying to connect the other device with my android application using wifimanager.i m getting the ip address o my android device using this code.but i could not get the port number of my android device working with wifi.How to get it??? please help me!!!! Thanks in advance...

 wifiManager = (WifiManager)context.getSystemService(context.WIFI_SERVICE); 
     wifiInfo = wifiManager.getConnectionInfo();
         int ipAddress = wifiInfo.getIpAddress();
         ip_Address=String.format("%d.%d.%d.%d",(ipAddress & 0xff),(ipAddress >> 8 &     `0xff),(ipAddress >> 16 & 0xff),(ipAddress >> 24 & 0xff));

`

هل كانت مفيدة؟

المحلول

When you talk about the port to which Wifi is connected then you are actually want to get the proxy port of the proxy host to which your Wifi is connected. To get such settings use the below library:

https://code.google.com/p/android-proxy-library/

Also look at below:

http://developer.android.com/reference/android/net/Proxy.html

There is no actual port related to Wifi or WLAN. Why do you want to get the port?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top