GPS provider, of course we all know, but it usually don’t work indoors. It relies on the GPS system with 27 satellites around the earth. At any time, a location needs to be in line-of-sight (LOS) of 4 satellites in order to get latitude, longitude and altitude. To calculate a location, the method is assuming the information from GPS satellite travels at speed of light in vacuum, and both GPS satellite and GPS receiver records the time of transmission and reception of the location data. The distance from GPS satellite to the receiver then can be calculated. 3 satellites are used fro two-dimensional triangulation to get (latitude, longitude), and the fourth satellite calculates the altitude. During this process, if time is out of sync, or GPS signals get reflected or diffracted by high buildings in big cities, errors will occur. To help with these limitations, modern mobile devices use assisted GPS (A-GPS), taking the advantage of mobile network to transmit GPS data.
Using wireless access points. WiFi works better indoors than GPS for sure, and WiFi radio often consumes less battery power than the GPS hardware. WiFi-based location detection works by having a device track what WiFi access points it can detect and the current signal strength of those access points. The device then makes a query to the Google location service (which is different from the Android location service), which provides location data based on the WiFi information. To provide location information based on visible WiFi access points, the Google location service must obtain information about WiFi access points and their locations. This information is collected by Android devices when a user enables use of Google’s location service in the Location Settings. This allows the device to record WiFi information as well as current location information (possibly provided by GPS) and transmit this information to Google. This essentially allows Google use each and every Android device as a way to update the WiFi location information and constantly maintain up-to-date data.
Additionally, cellular network is used in a similar way as WiFi access points to determine device location. A cellular device must be in contact with a cell tower. As a device moves, it may connect to a different cell tower as the signal strength of an approaching cell tower becomes stronger. Knowing the unique ID of the tower that a device is currently connected to, and possibly the towers that a device was previously connected to, can provide insight to where the device is located assuming the location of a given cell tower is known.