Skip to content

Conversation

katjajohanna
Copy link

This fixes the exception when building the application:

react-native-android-wifi/android/src/main/java/com/devstepbcn/wifi/AndroidWifiModule.java:49: Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing reactContext to reactContext.getApplicationContext()  [WifiManagerLeak]
  wifi = (WifiManager)reactContext.getSystemService(Context.WIFI_SERVICE);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   Explanation for issues of type "WifiManagerLeak":
   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. Change context.getSystemService(...) to
   context.getApplicationContext().getSystemService(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant