why getSpeed() always return 0 on android

前端 未结 11 1285
半阙折子戏
半阙折子戏 2020-11-28 07:35

I need to get the speed and heading from the gps. However the only number i have from location.getSpeed() is 0 or sometimes not available. my code:

         


        
11条回答
  •  执念已碎
    2020-11-28 08:12

    I also encountered this problem before, I hope this can help.

    It returns 0 because your device cannot get a lock on the GPS, or cannot connect to the GPS.

    I tried to get the speed using an older lenovo device and it returns 0 because it cannot lock on a gps.

    I tried using a samsung galaxy nexus and it returned my speed(has a better GPS sensor).

    The GPS sensor in your phone might not be good or you are in an area that has a weak GPS signal such as inside a house or building.

提交回复
热议问题