2

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

Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46
  • Is your `Location` enabled in settings. If it is enabled, then only you will be getting location otherwise it will return null. – Vipul Asri Jan 19 '16 at 12:10
  • It is disabled. If it only works using `Location` enable in settings then what's the purpose of saying that `FusedLocationProvider` will get the location from cellular tower – Mustansar Saeed Jan 19 '16 at 12:23

1 Answers1

2

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.

mattm
  • 5,851
  • 11
  • 47
  • 77
  • This is important point that `APIs` dont work if user has explicitly turned the settings off. If our application requires location for some feature then we can restrict that user for usage if location is disabled. – Mustansar Saeed Oct 28 '19 at 04:46