How to get the connection strength of Wifi access points?

前端 未结 5 1949
谎友^
谎友^ 2020-12-05 01:09

I am building an application reading the signal strength of each available Wifi access point.

I\'ve written code like:

    wifi = (WifiManager) getS         


        
5条回答
  •  旧巷少年郎
    2020-12-05 02:01

        WifiManager wifiManager = (WifiManager)
        MonitorActivity.this.getSystemService(Context.WIFI_SERVICE);
    
        wifiManager.addNetwork(conf);
    
        int numberOfLevels = 5;
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
    
        Log.e("level", "" + level);
        // you will get the levels. Using these levels you can calculate strenghts.
    

提交回复
热议问题