Search code examples
androidgoogle-play-servicesfusedlocationproviderapiandroid-fusedlocation

Fetch offline location using FusedLocationApi


I want to fetch the location using google play services LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); when GPS/Wifi is turned off. Reading the articles/blogs regarding FusedLocationApi, its mentioned that this API will provide the accurate location using any of GPS/Wifi or Cellular network. I am confused that if cellar network can provide the location then FusedLocationApi should return the location if Gps/Wifi is disabled but its returning null. Can anyone please let me help/guide to fetch offline location using cellular network.

Regards


Solution

  • You cannot get location using the cellular network through the standard API when GPS and WiFi location are disabled.

    The device must have location enabled in order for an application to retrieve location. This is a basic permissions issue for the end user; if the end user requests that no location be available, then no location is available.

    When retrieving location, there are two sources of information:

    1. GPS: This uses satellites in space to locate the device. GPS provides the most accurate location, but is slow, especially if you do not have a data connection. On the device this is the "device only" mode.

    2. Network: This uses WiFi and/or the cellular network. There is not a way to choose WiFi and cellular location separately. When you get a location update, the horizontal accuracy is a strong indicator of whether WiFi or the cellular network was used. WiFi accuracy should be in 10's of meters, while cellular will probably be 100's of meters. If you are in an area without WiFi coverage but with cellular coverage, then the network source will still provide location updates.

    You can also use both these sources. This is the "high accuracy" location mode.

    If you turn both of these off (disable location), then you will not get any location.