Android-based Wi-Fi signal strength acquisition

Source: Internet
Author: User

1. 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 wifi: 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 ();}

2. Register a receiver to listen for Wi-Fi signal changes:

public BroadcastReceiver rssiReceiver = new BroadcastReceiver() {        @Override        public void onReceive(Context context, Intent intent) {        }    };    @Override    public void onResume() {        super.onResume();        registerReceiver(rssiReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));                Log.d("way", "Registered");    }    @Override    public void onPause() {        super.onPause();                unregisterReceiver(rssiReceiver);        Log.d("way", "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.