Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Getting the signal strength of WI-FI in percentage in android devices.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 4.75k
    Comment on it

    If you need to display WI-FI signal strength in percentage than you just have put this method getWifiStrengthPercentage in your utility class and call it whenever you need the Signal information.

     public static int getWifiStrengthPercentage(Context)
     {
          try
          {
              WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
              int rssi = wifiManager.getConnectionInfo().getRssi();
              int level = WifiManager.calculateSignalLevel(rssi, 10);
              int percentage = (int) ((level/10.0)*100);
              return percentage;
          }
          catch (Exception e)
          {
              return 0;
          }
    }
    

    We need to pass context of the activity from where we are calling this method.

    You will get WI-FI strength in percentage. In case if any exception found then it will return 0;

    Don't forget, you should declare the permission in your manifest:

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    

    Hope you find it helpful.... :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: