Why does having Wifi on but not connected help Network location, when using LocationManager?

回眸只為那壹抹淺笑 提交于 2019-12-05 04:58:10

Android, Apple and other companies have access to a huge data base where they can look up Wlan-Device-Id (the Mac-Adress of your WLAN Router) to lat/lon coordinates.
So when your phone detects a "known" WLAN, it can either:
- look up a local cache of Wlan-id to coordinate, or if you have internet connection active,
- it can connect and query the coordinate for the Wlan id via that data base.

Remains the question where they have the coordinate of your WLAN-id?
Probably the first time when you have GPS active while connected to your WLAN.

SkyHook is such a company that provides that data.

From the LocationManager API:

public static final String NETWORK_PROVIDER

Added in API level 1 Name of the network location provider.

This provider determines location based on availability of cell tower and WiFi access points. Results are retrieved by means of a network lookup.

Constant Value: "network"

Even though you are not connected to any access points, your phone can still detect them and use this location info when calling:

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