Android gets Wi-Fi signal quality and signal strength

Source: Internet
Author: User
Android gets the Wi-Fi signal quality edit | Delete int strength = wifimanager. calculatesignallevel (info. getarg (), 5), that is, the signal strength.

Method:

Private string obtainwifiinfo (){

// WiFi connection speed and signal strength: 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 (); // The 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 the supervisor,
Public broadcastreceiver rssireceiver = new broadcastreceiver (){
@ Override public void onreceive (context, intent) {// todo auto-generated method stub log. D ("RSSI", "RSSI changed"); // wifiinfo. settext (obtainwifiinfo ());
}}; @ Override public void onresume () {super. onresume (); registerreceiver (rssireceiver, new intentfilter (wifimanager. rssi_changed_action); log. D ("RSSI", "registered ");}
@ Override public void onpause () {super. onpause (); unregisterreceiver (rssireceiver); log. D ("RSSI", "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.