Manifest file
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" ></uses-permission>
Main.java
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); Log.d("wifiInfo",wifiInfo.toString());
Explanation
First we need to get our Wifi service, WifiManager class is pretty much the class you need for wifi connectivity.
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
Get the infomration of the current wifi connection information with getConnectionInfo
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
For now we trace our connection
Log.d("wifiInfo",wifiInfo.toString())
I got this result since i didnt turn on my wifi, you could turn your wifi on via settings and try to trace it again.
SSID:
References
WifiManager
WifiInfo
http://www.google.com/codesearch/p?hl=en#8ckgoBxhL4o/trunk/src/android/tether/TetherApplication.java&q=WiFi%20android
Update History
Jan 17, 2012 - Visual Update
No comments:
Post a Comment