Error:Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing to .getApplicationContext() [WifiManagerLeak]
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
替换成下面的:
WifiManager wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
然而生成APK的时候还是报错:
Error:Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing this to this.getApplicationContext() [WifiManagerLeak]
换成
WifiManager wifi = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
犯了错,总之要改,改之后呢,最好还是记录。因为这些难题在后来的日子还是会遇到。不妨到时候回过头看看自己当时记录的错误。毕竟是自己的错,资以改正。
纸上得来终觉浅,书到用时方恨少。希望对你有所帮助。
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/115072.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...