Permissions Journey: ACCESS_WIFI_STATE

Public on May 26, 2009
ACCESS_WIFI_STATE allows applications to access information about Wi-Fi networks, pretty much explained it all.

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: , BSSID: , MAC: 00:18:41:c8:62:98, Supplicant state: UNINITIALIZED, RSSI: -200, Link speed: 54, Net ID: -1

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




[Advertising]Faster Thinking - Speed up your brain


Faster Thinking Game



sentiment_satisfied Emoticon