3

In GPS_PROVIDER using location.getSpeed() working correct and it gets a current speed. But in NETWORK_PROVIDER it always shows speed 0. I'm only testing in device not emulator.

Thomas R.
  • 7,988
  • 3
  • 30
  • 39
rohit
  • 107
  • 2
  • 7

4 Answers4

3

Gps provider gives location accuracy within 5-15 meter so when you call method location.getSpeed() then it gives correct location Where as Network provider does not gives accurate location it gives location within 100 meter so when you call location.getSpeed() then it does not know where you are accurate between 100 meter.

Yogesh Ude
  • 121
  • 5
  • 1
    already i used this its working correct but now only it always shown 0 – rohit Jul 24 '14 at 08:19
  • 1
    Because it speed is calculated when your latitude and longitude co-ordinate changes but in network provider it remains same you will get latitude and longitude of from same tower so it will not gives accurate latitude,longitude,accuracy and barrier so speed depends on this factor. – Yogesh Ude Jul 24 '14 at 08:49
  • you will only get a getSpeed() value if your accuracy is at least better than 10 m (not 100% sure about this value)l – Dennis Nov 12 '15 at 10:46
3

In NETWORK_PROVIDER hasSpeed() return false, so your location.getSpeed()=0. You can use getspeed() only for GPS_PROVIDER.

Davit Avetisyan
  • 129
  • 1
  • 9
  • Exactly the right answer. I wonder no one has not upvoted this until now!!! I am upvoting this – Nik Jan 26 '17 at 19:34
1

NETWORK_PROVIDER provides your location according to your network,to which cell tower you are connected if you are on mobile network or router you are connected if you are using wifi,so if the location of cell tower or router for your NETWORK_PROVIDER is unchanged it gives 0

Pramod Yadav
  • 2,316
  • 2
  • 23
  • 36
0

Reference Here: Determining the speed of a vehicle using GPS in android

AFAIK, Speed can/should be calculated only with GPS_PROVIDER. Network provider data depends on some parameters like the carrier network, tower, signal strength etc.. So, it is not the right method to determine speed. Also, it will return the same lat long for a larger distance since it is based on a static tower.

The accuracy of lat long of NETWORK provider is very low compared to GPS Provider and would not be sufficient and should not be used to calculate speed.

Community
  • 1
  • 1
ngrashia
  • 9,869
  • 5
  • 43
  • 58