作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试构建我的应用时出现以下错误:
Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing this.cordova.getActivity() to this.cordova.getActivity().getApplicationContext() [WifiManagerLeak]
Intent settingsIntent = new Intent(Settings.ACTION_WIFI_SETTINGS);
^
Explanation for issues of type "WifiManagerLeak":
On versions prior to Android N (24), initializing the WifiManager via
Context#getSystemService can cause a memory leak if the context is not the
application context. Change context.getSystemService(...) to
context.getApplicationContext().getSystemService(...).
2 errors, 0 warnings
我正在使用节点v6.11.2,cordova 6.5.0和cordova-android 6.4.0和gradle 4.1
最佳答案
如Github issue中所述,使用已弃用的api-22
分支将导致此错误,因为不再维护该错误。从master分支切换到使用发行版,它将通过cordova-android@6.4.0
和Gradle 4很好地构建。cordova-diagnostic-plugin
和cordova-android@6.4.0
的master分支都向后兼容API 16。
关于android - Cordova:错误:必须在Application上下文中查找WIFI_SERVICE,否则在<Android N,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47315928/
在 android 中,蓝牙适配器是使用 getDefaultAdapter() 调用访问的,但是 WifiManager 和连接管理器是使用 getSystemService(Context.WIF
我是一名优秀的程序员,十分优秀!