-2

I am developing an Android application in which I am using current location of my device. I am using requestLocationUpdates("gps", 5000, 0, new LocationDetector()); method of LocationManager for getting updates. And inside onLocationChanged() method of LocationListener I am making use of my device's current location. Now:

Question#1: I have recorded that the current location detected by "gps" as well as by NETWORK_PROVIDER has some error (error means my device's location is not exactly that which is returned by "gps" or "network_provider"). So I want to know that what is the maximum error that can be there in the result of "gps" and NETWORK_PROVIDER? And is there any way to get accurate results from "gps" and NETWORK_PROVIDER?

Question#2: In my device, "gps" does not works within closed areas (like room), so I want to make use of "gps" as well as NETWORK_PROVIDER for getting location's updates. So that when my device's "gps" is not working, I should automatically get updates through NETWORK_PROVIDER. So please tell how can I do that?

Sajal Ali
  • 427
  • 1
  • 10
  • 21

1 Answers1

1

Question 1

Each provider has pros and cons, gps gives more accurate results with more power usage. Network provider gives less accurate results with less power usage. You can combine gps and network providers but there is already a provider which wraps all things under the hood for you : fused location provider

Question 2

Yes, you can implement a simple timeout mechanism on gps provider. So when timed out, start location requests for network provider.

But i suggest watching this video. So it's good explanation for your second question.

blackkara
  • 4,900
  • 4
  • 28
  • 58