Search code examples
androidandroid-intentandroid-wifi

Intent on wifi signal strength change


I want to open my app when my wifi signal gets below 20% How do i implement this?? below is the code for wifi signal strength

 WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
     final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
      int rssi = connectionInfo.getRssi();
        int level = WifiManager.calculateSignalLevel(rssi, 10);
        int percentage = (int) ((level/10.0)*100);

Solution

  • One solution is to write a small service that periodically checks for signal strength, and opens your app once the 20% level is crossed. Beware of excessive battery use with something like this.