WifiManager Potential Leak
WifiManager Potential Leak
On versions prior to Android N (24), initializing the WifiManager
via Context#getSystemService
can cause a memory leak if the context is not the application context.
In many cases, it's not obvious from the code where the Context
is coming from (e.g. it might be a parameter to a method, or a field initialized from various method calls). It's possible that the context being passed in is the application context, but to be on the safe side, you should consider changing context.getSystemService(...)
to context.getApplicationContext().getSystemService(...)
.
Issue id: WifiManagerPotentialLeak
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for Android 2023.3, Qodana for JVM 2023.3 |
Plugin: | Android, 2022.3.1 Beta 2 |
Last modified: 13 July 2023