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

前端 未结 17 1767
时光取名叫无心
时光取名叫无心 2020-11-22 08:53

How can I check the current status of the GPS receiver? I already checked the LocationListener onStatusChanged method but somehow it seems that is not working,

17条回答
  •  温柔的废话
    2020-11-22 09:31

    Setting time interval to check for fix is not a good choice.. i noticed that onLocationChanged is not called if you are not moving.. what is understandable since location is not changing :)

    Better way would be for example:

    • check interval to last location received (in gpsStatusChanged)
    • if that interval is more than 15s set variable: long_interval = true
    • remove the location listener and add it again, usually then you get updated position if location really is available, if not - you probably lost location
    • in onLocationChanged you just set long_interval to false..

提交回复
热议问题