get Wifi Strength - Android android.net.wifi

Android examples for android.net.wifi:Wifi Property

Description

get Wifi Strength

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import java.util.List;

public class Main{

    public static int getWifiStrength(ScanResult result) {
        try {/*from  w ww  .  ja  va2s  . co  m*/
            int level = WifiManager.calculateSignalLevel(result.level, 10);
            int percentage = (int) ((level / 10.0) * 100);
            return percentage;
        } catch (Exception e) {
            return 0;
        }
    }

}

Related Tutorials