Reprinted: http://www.cxybl.com/html/android/20120428/23302.html
Android gets Wi-Fi signal strength
Android gets the Wi-Fi signal quality: int strength = wifimanager. calculatesignallevel (info. getarg (), 5); that is, the signal strength. Obtaining method: Private string obtainwifiinfo () {// connection speed and signal strength of wifi: wifimanager
= (Wifimanager) getsystemservice
Android gets Wi-Fi signal quality:
Int strength = wifimanager. calculatesignallevel (info. getarg (), 5); that is, the signal strength.
Method:
Private string obtainwifiinfo (){
// Connection speed and signal strength of Wi-Fi:
Wifimanager = (wifimanager) getsystemservice (wifi_service );
// Wifiinfo = wifimanager. getconnectioninfo ();
Wifiinfo info = wifimanager. getconnectioninfo ();
If (info. getbssid ()! = NULL ){
// Link signal strength
Int strength = wifimanager. calculatesignallevel (info. getarg (), 5 );
// Link speed
Int speed = info. getlinkspeed ();
// Link speed unit
String Units = wifiinfo. link_speed_units;
// WiFi source name
String SSID = info. getssid ();
}
Return info. tostring ();
}
/// // The Wi-Fi signal changes:
Register aggreger,
Public broadcastreceiver rssireceiver = new broadcastreceiver (){
@ Override
Public void onreceive (context, intent ){
}
};
@ Override
Public void onresume (){
Super. onresume ();
Registerreceiver (rssireceiver, new intentfilter (wifimanager. rssi_changed_action ));
Log. D ("Arg", "registered ");
}
@ Override
Public void onpause (){
Super. onpause ();
Unregisterreceiver (rssireceiver );
Log. D ("Arg", "unregistered ");
}