How can I check if GPS is enabled before I try to use it

后端 未结 3 1855
鱼传尺愫
鱼传尺愫 2021-02-14 03:27

I have the following code and it\'s not good because sometimes GPS takes very long

How can I do the following:

  1. Check if GPS is enabled
  2. Use GPS if
3条回答
  •  别跟我提以往
    2021-02-14 04:31

    Think you could use the code in my answer to: Location servise GPS Force closed

    It gives you a callback method for GPS first fix and location changes that can be very convenient. This also makes it easy to change the implementation of GPSTracker to switch to network if GPS takes too long to get a first fix.

提交回复
热议问题