1

After few hours of testing outside of house, when i came back to my house i found that GPS is enabled but was not getting location fixes inside the building.Hence its onLocationChanged method couldn't get called.

Problem: How to know that GPS is not getting any location fixes as device continue to sense your location in "trying mode".By trying mode i mean the situation where it is not coming to any result even after 20 to 30 minutes still it declared it self as enabled (blinking in status bar).

How one could know that the GPS doesn't get location so switch to another provider like Network_Provider.

In short i want to get my device to conclude something that GPS can find location fix for sure or you have to take location by another means.

I hope at least someone can give me idea about how to deal with that.

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
kaushal trivedi
  • 3,405
  • 3
  • 29
  • 47

1 Answers1

4

The link below has an awesome tutorial, of how to get the location from GPS and/or Network.

It uses a timer task, which analyzes if there is a GPS location in a specific period of time, assume 20 seconds. If not, it will return the location from Network as the current location. If there is a location from GPS, then it will compare which update is new (latest), and return that.

What is the simplest and most robust way to get the user's current location on Android?

Community
  • 1
  • 1
nithinreddy
  • 6,167
  • 4
  • 38
  • 44