您的位置:首页 > 移动开发

打包时报错: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devic

2018-01-29 15:03 746 查看
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);

改一下即可!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐