Android gets Wi-Fi signal strength

Source: Internet
Author: User

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 ");
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.