hoerresb / WifiWizard

A Cordova plugin for managing Wifi networks
Apache License 2.0
205 stars 178 forks source link

Fix memory leak on android #122

Open Maikell84 opened 6 years ago

Maikell84 commented 6 years ago

Gradle linter gives a warning:

:lintVitalRelease/home/michael/Projects/smart-mirror/application/platforms/android/src/com/pylonproducts/wifiwizard/WifiWizard.java:57: Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing cordova.getActivity() to cordova.getActivity().getApplicationContext() [WifiManagerLeak]
this.wifiManager = (WifiManager) cordova.getActivity().getSystemService(Context.WIFI_SERVICE);

This PR resolves it.

tripflex commented 6 years ago

Thanks for this, I created a fork of WifiWizard (named WifiWizard2), and added this PR to it, along with credit for you in the changelog: https://github.com/tripflex/WifiWizard2