Missing method in android.net.wifi.WifiManager

时光怂恿深爱的人放手 提交于 2019-12-01 21:01:09

问题


On the site androidjavadoc.com, a method startScanActive is listed in the class WifiManager that makes it possible to perform an active wi-fi scan. It has been discussed here recently, too.

Nevertheless, when I try to use that method in Eclipse, it is not found (undefined). startScan is. I tried that with all android.jar versions coming with the Android SDK (from 2.3 to 3.1).

Does the function exist? How can I get access to it?

Thanks a lot


回答1:


As I mentioned, look at the official documentation. It's not there. As such, it's not part of the public API, and you should not call it. Even if it's public, it doesn't mean that you can call it.

Undocumented API calls can disappear without notice at any time in future versions, which will cause your app to break.




回答2:


Here goes my own explanation, based on the cited resources: The function is not contained in the Android SDK. In the source code, it is marked with the Javadoc tag @hide (source), which causes it to be excluded from the documentation but also not to be compiled for the SDK. For testing purposes, an own jar file may be compiled and used. But on the cell phone itself, it will depend on the vendor if the method will be present.

Similar question. Post on androidjavadoc.com.




回答3:


When everything else fails, go to the roots:

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/net/wifi/WifiManager.java#WifiManager.startScanActive%28%29

It is a public method in WifiManager since 1.6, although you're correct in saying that Eclipse does not find that method, for some weird reason.



来源:https://stackoverflow.com/questions/6234728/missing-method-in-android-net-wifi-wifimanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!