Wednesday, February 22, 2012

Android Wifi Connected info such as signal strength

WifiManager mainWifi;
String cSummary="Not Connected" ;
mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = mainWifi.getConnectionInfo();
if(wifiInfo.getBSSID()!=null){
int strength=WifiManager.calculateSignalLevel(wifiInfo.getRssi(), 5);
int speed=wifiInfo.getLinkSpeed();
String units=WifiInfo.LINK_SPEED_UNITS;
String ssid=wifiInfo.getSSID();
cSummary=String.format("Connected to %s at %s%s. Strength %s/5", ssid,speed,units,strength);
if(strength==1)play();
}
return cSummary;

2 comments:

  1. can you give me the java,xml, and manifest???? im newbie in android ^_^

    ReplyDelete
  2. http://andbrain.com/blog/category/andbrain/

    ReplyDelete