title: exceeded maximum number of wifi locks android
body: <p>I am sending <code>latitude</code> and <code>longitude</code> every 5 min to server at the time i am acquiring <code>WakeLock</code> and <code>WifiLock</code> but getting error </p>
  
  <pre><code>java.lang.UnsupportedOperationException: Exceeded maximum number of wifi locks
  at android.net.wifi.WifiManager$WifiLock.acquire(WifiManager.java:1622)
  </code></pre>
  
  <p>code of snippet is,</p>
  
  <pre><code>public class WakeLocker {
      private WakeLock wl_cpu;
      private PowerManager mPowerManager;
      private WifiLock wifiLock = null;
  
      @SuppressLint({ "InlinedApi", "Wakelock" })
      public void acquire(Context ctx) {
          mPowerManager = (PowerManager) ctx
                  .getSystemService(Context.POWER_SERVICE);
  
          WifiManager wm = (WifiManager) ctx
                  .getSystemService(Context.WIFI_SERVICE);
          wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF,
                  "MyWifiLock");
          wifiLock.acquire();
  
          wl_cpu = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
                  | PowerManager.ACQUIRE_CAUSES_WAKEUP
                  | PowerManager.ON_AFTER_RELEASE, "MyCpuLock");
          wl_cpu.acquire(10000);
      }
  
      public void release() {
  
          if ((wifiLock != null) || (wifiLock.isHeld() == true)) {
              wifiLock.release();
              wifiLock = null;
          }
          if ((wl_cpu != null) || (wl_cpu.isHeld() == true)) {
              wl_cpu.release();
              wl_cpu = null;
          }
  
      }
  }
  </code></pre>
  
  <p>Not getting any solution. Please any suggestion.
  Thank you in advance.</p>