0

I'm currently developing an app with friends of mine and right now I can check if GPS is enabled or not. Now I need to check if GPS is receiving signal or not. I've read a few threads on stackoverflow such as :

How can I check the current status of the GPS receiver?

Thing is these are pretty old and I've tried that code and some of the methods looks like they don't even exist anymore.

Do you guys know of any changes there have been or if that code is supposed to still work ?

Thanks for reading.

Community
  • 1
  • 1
NetworkzZz
  • 49
  • 1
  • 8

1 Answers1

0

Define receiving signal. GPS can really be in 1 of 4 states:

1)Disabled- unless the user enables it it is off and cannot be turned on 2)Off- GPS is enabled at a system level, but the radio is not currently on 3)Locking- GPS is enabled and the radio is on, but we do not yet have a lock on enough sattelites t get a location 4)On- the GPS is enabled, the radio is on, and we have a lock

1 is trivial to check- LocationManager.isProviderENabled will tell you that.

2 is possible to get through a GPSStatusListener, by calling LocationManager.addGpsStatusListener and the current state via LocationManager.getGPSStatus. The state GPS_EVENT_STOPPED should be here

3 is possible via the same method as 2, the event GPS_EVENT_STARTED should occur when we enter this state

4 also possible through status, the other 2 events mean we're in this state. FIRST_FIX means we're just entering it.

Also from a user perspective you can tell 2 from 3 from 4 via the GPS symbol in the notification bar- 1 and 2 have no symbol, 3 has a flashing one, and 4 has a solid one.

Which of these states you care about depends on your app. Frequently 2 and 3 can be treated the same- no signal, but enabled.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127