• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get already set wireless access point details

 
NeelNisha Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
since we can set wireless access point in android device from device settings,Actually then through android application i want to
retrieve already set access point information like name,ip address,port number etc.Any idea/sample code/links how to do this?
I have gone through APIs in android.net.WiFi also but not getting proper solution,Please help
 
NeelNisha Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have also tried :
List<WifiConfiguration> results= wifi.getConfiguredNetworks();
int sizeConfigured=result.size();

I got wifi.getConfiguredNetworks() returns list of already configured wifi network list,But getting nullpointer exception ,
Please help....
 
NeelNisha Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am posting full code also what i have tried
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you getting the exception? Which object is null?


Don't ever do this, it's a bad idea. How will you know if there are problems? At least print the exception message to where you will see it (like the logcat).
 
NeelNisha Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for the reply
I am getting exception at the place where i have fetched

sizeConfigured=results1.size();

at line number 39 in above posted code,got this from logcat
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, the javadocs of the getConfiguredNetworks method mention that it can return null under certain circumstances, so you need to check for that.
 
NeelNisha Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes when Wi-Fi is turned off, it can be null.

Please tell me Am I going on right way for getting information of already configured WiFi access point in android device,
as i have mentioned in above question also
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not going to work, as the javadocs of the startScan method explain:

Unfortunately, it doesn't mention how to receive the event that signals when the scan has finished, but here's an example of how to do that: http://www.androidsnippets.com/scan-for-wireless-networks
 
NeelNisha Singh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply and link!!

Actually scenario is for example in my android device i have configured wi-fi access point is "abc" ,and after wi-fi scanresult suppose it detected(As per javadoc) 4 results eg
"abc","def","fgrd","rude".Then I need to check if scanresult list contains configured wi-fi name i.e "abc" then i need to establish connection with "abc"
only and at android side in client code i need to pass only set wi-fi "abc" information like ip address,port number for receiving and sending data.

Please help Ulf .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic