4

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

Community
  • 1
  • 1
filip
  • 3,542
  • 1
  • 26
  • 23
  • Why don't you look at the official documentation? It does exist, since API level 1. Can you show your code? Here: http://developer.android.com/reference/android/net/wifi/WifiManager.html#startScan%28%29 – EboMike Jun 04 '11 at 04:49
  • I refer to the method startScanActive, not startScan. The code is simple: wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifi.startScanActive(); – filip Jun 04 '11 at 04:56

3 Answers3

3

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.

EboMike
  • 76,846
  • 14
  • 164
  • 167
  • 1
    Thanks, but my questions are not answered yet: Does it exist? How to get access to it? For a public, compatible application you are right. Better not use unofficial APIs. But you don´t know the case. For a company internal application tracking its employees it may absolutely make sense to use that function, if the device is known. Active scans allow a much faster discovery of APs. – filip Jun 04 '11 at 19:59
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.

Community
  • 1
  • 1
filip
  • 3,542
  • 1
  • 26
  • 23
  • http://groups.google.com/group/android-developers/browse_thread/thread/549eab06c643223b?pli=1 – filip Jun 05 '11 at 02:52
0

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.

Aleadam
  • 40,203
  • 9
  • 86
  • 108
  • Thanks a lot! I analyzed the jar files shipped by the Android SDK and the method is definitely not contained in them. So it´s not Eclipse´s fault... – filip Jun 05 '11 at 01:30
  • If, as you said in the comment, is for internal use, you should have no problem compiling the sources yourself with that method included, or modifying startScan(). It is just a matter of one boolean: `mService.startScan(true);` – Aleadam Jun 05 '11 at 01:38
  • Yeah, thanks. First I try compiling android for the PC in order to code and hope that the method is available on the cell phones. – filip Jun 05 '11 at 02:40