signed apk error [WifiManagerLeak]

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);

犯了错,总之要改,改之后呢,最好还是记录。因为这些难题在后来的日子还是会遇到。不妨到时候回过头看看自己当时记录的错误。毕竟是自己的错,资以改正。


纸上得来终觉浅,书到用时方恨少。希望对你有所帮助。


posted @ 2017-06-28 16:52  冷冷清清风风火火是我  阅读(93)  评论(0)    收藏  举报