Fixed Wifi mangager memory leak on devices < N (#811)

AndroidStudio reported the error:
Error: The WIFI_SERVICE must be looked up on the Application context or
memory will leak on devices < Android N. Try changing
to .getApplicationContext()  [WifiManagerLeak]
This commit is contained in:
Philipp Hasper 2017-06-08 15:17:45 +02:00 committed by Sean Owen
parent f4266e0a51
commit da4e333d66

View file

@ -61,7 +61,7 @@ public final class WifiResultHandler extends ResultHandler {
public void handleButtonPress(int index) {
if (index == 0) {
WifiParsedResult wifiResult = (WifiParsedResult) getResult();
WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
WifiManager wifiManager = (WifiManager) getActivity().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null) {
Log.w(TAG, "No WifiManager available from device");
return;