From da4e333d66cb55e610e83df5811539af605acc4b Mon Sep 17 00:00:00 2001 From: Philipp Hasper Date: Thu, 8 Jun 2017 15:17:45 +0200 Subject: [PATCH] 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] --- .../google/zxing/client/android/result/WifiResultHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/com/google/zxing/client/android/result/WifiResultHandler.java b/android/src/com/google/zxing/client/android/result/WifiResultHandler.java index 6cd8a277f..3720371d3 100644 --- a/android/src/com/google/zxing/client/android/result/WifiResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/WifiResultHandler.java @@ -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;