Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing ac to ac.getApplicationContext() [WifiManagerLeak]
问题原因:
WifiManager wifi = (WifiManager) ac.getSystemService(Context.WIFI_SERVICE);
log上也说明了,在android N以上要用ac.getApplicationContext()来获取
所以解决办法也就很简单了:
WifiManager wifi = (WifiManager) ac.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
改一下即可,ac就是activity的上下文!