why getSpeed() always return 0 on android

前端 未结 11 1284
半阙折子戏
半阙折子戏 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:25

    Hey I too was suffering from the same but now I have got it solved ! Just multiply the value by 18/5 , it gives almost the accurate value.

    speed=location.getSpeed()*18/5

    Also specify the interval as 1000*2 and fastest interval as 1000*1 for more accuracy

提交回复
热议问题