Android Nought(7.0)미만에서 WindowWifi사용시 메모리 누수문제
Android Document
WifiManager
public class WifiManager
extends Object
This class provides the primary API for managing all aspects of Wi-Fi connectivity.
On releases before Build.VERSION_CODES.N, this object should only be obtained from an Context#getApplicationContext(), and not from any other derived context to avoid memory leaks within the calling process.
StackOverflow
As the error suggests, it seems that WiFiManager must use the ApplicationContext, as opposed to the ActivityContext, otherwise a memory leak can occur. The error was triggered by following code:
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
To fix the issue I replaced the above line with:
WifiManager wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
수정전
wifiManager = context.getSystemService(Context.WIFI_SERVICE) as WifiManager
수정후
wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
Document: https://developer.android.com/reference/android/net/wifi/WifiManager
StackOverflow: https://stackoverflow.com/questions/42621010/signed-apk-error-wifimanagerleak