Android: check if GPS is searching, has fix or is not in use

后端 未结 2 388
陌清茗
陌清茗 2020-12-11 06:34

I want to know if there is a way in Android (GingerBread) to know if at the moment the GPS is doing something or not. Let me be a bit more clear: I basically want to call so

2条回答
  •  既然无缘
    2020-12-11 06:44

    Unfortunately, there's no easy way to get the "current state" of the GPS in Android. Like others have pointed out, your best bet is to register for the onGpsStatusChanged() event and track the state.

    If you are feeling adventurous, you can call call $ dumpsys location from an adb shell to get the state of the gps provider. You usually call $ adb shell from your desktop, but you can compile a native android shell app, and call an exec() from inside the shell to get the dumpsys output directly on the phone.

提交回复
热议问题