java - 我在 android 5.0.2 源中找到 WIFI_SCANNING_SERVICE 但无法使用此服务

标签 java android wifi

我想指定 wifi 的频率(或信道)以加快 wifi 扫描。

我研究过android 5.0.2源码,发现 android.net.wifi.WifiScanner Android API 中的类。这个类的评论是这样说的

This class provides a way to scan the Wifi universe around the device Get an instance of this class by calling Context.getSystemService(Context .WIFI_SCANNING_SERVICE).

但是当我尝试使用以下代码使用它时:

Context.getSystemService(Context .WIFI_SCANNING_SERVICE)

在Android Studio 1.0(SDK:android 21 for complie)中,IDE提示没有这样的“WIFI_SCANNING_SERVICE”,尽管在文档中有描述。

我还在 android.net.wifi.WifiManager 类中尝试了 startCustomizedScan(ScanSettings requested) 但我收到一条错误消息“没有这样的功能”。

此函数已记录 here

请告诉我如何使用上述服务和/或功能。

最佳答案

您不能按原样使用 Context.WIFI_SCANNING_SERVICE 静态变量 marked作为 @SystemApi。如评论 here 中所述,系统 API 不打算供其他标准 Android 应用程序使用。 :

...These APIs are not guaranteed to remain consistent release-to-release, and are not for use by apps linking against the Android SDK...

关于java - 我在 android 5.0.2 源中找到 WIFI_SCANNING_SERVICE 但无法使用此服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29557034/

相关文章:

java - Webview 加载对话框

android - 模块依赖 - Android Studio

java - 在自定义线程中创建的对象在主线程上运行

java - 如何告诉 Spring Boot 将哪个主类用于可执行 jar?

android - RX sub observable - 只执行一次

ios - 等待进入 Controller ,直到 wifi 启用 IOS

python - 是否可以在不连接网络的情况下通过 wifi 发送 UDP 广播?

java - android 问题 - 套接字失败

java - 图像处理java

java - 如何从 Javalin 读取多个主体参数?