Android studio编译错误二:Error: The WIFI_SERVICE must be looked up on the Application
来源:互联网 发布:软件开发cmm 编辑:程序博客网 时间:2024/05/29 17:47
编译错误
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]
原因
Android 7.0 在获取 WifiManager的时候需要使用.getApplicationContext(),如果未使用会造成内存泄露。
解决方法
原来的:
WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
修改为:
WifiManager wifiManager = (WifiManager)getApplicationContext().getSystemService(WIFI_SERVICE);
阅读全文
1 0
- Android studio编译错误二:Error: The WIFI_SERVICE must be looked up on the Application
- Android studio编译错误二:Error: The WIFI_SERVICE must be looked up on the Application
- Android studio编译错误 Error: The WIFI_SERVICE must be looked up on the Application
- The WIFI_SERVICE must be looked up on the Application
- 【Android】- Error:The<activity>element must be a direct child of the <application> element[WrongMani]
- Android Studio 3 Error Message:The activity must be exported or contain an intent-filter
- WARNING: The host '$hostname' could not be looked up with resolveip.
- WARNING: The host 'localhost' could not be looked up with /usr/local/mysql//bin/resolveip
- Main application must be in the list of application paths
- setTag使用错误The key must be an application-specific resource id.
- mysql 安装错误:FATAL ERROR: Neither host '* nor 'localhost' could be looked up with /usr/bin/resolveip
- Android Studio 编译布局文件错误之:Rendering Problems The following classes could not be instantiated
- Android -- setTag的妙用和The key must be an application-specific resource id 异常
- android setTag的妙用和The key must be an application-specific resource id 异常
- Android解决:View.setTag(key,object)异常:The key must be an application-specific resource id.
- 导入adt项目进入android studio报Error:(2) Error parsing XML: prefix must not be bound to one of the reserved
- anroid studio更新中出现The Android SDK folder can no longer be inside the application......
- [Android]All WebView methods must be called on the same thread.线程安全
- python安装pyserial
- Spring Boot Web API测试
- 【Opencv】 于仕琪 人脸68个特征点分布情况
- Servlet的@WebServlet注解
- Android_EventBus简单传值
- Android studio编译错误二:Error: The WIFI_SERVICE must be looked up on the Application
- Leetcode Minimum ASCII Delete Sum for Two Strings
- java 字符串转json
- asp.net 连接sql server 插入
- Linux 里的 (#暗物质*) session 跨域问题
- Warning:android-apt plugin is incompatible with future version of Android Gradle plugin. Please use
- Android,安卓,toolbar,menu显示位置,及样式调整,及使用PopupWindow 实现menu下拉菜单gong
- 程序猿生涯第一步
- hdu 2586 How far away ?(LCA转RMQ~)