I am using fused location provider from the new GooglePlay API(LocationClient class). But the method Location.GetSpeed() is not returning correct speed (shows 0). I read that I have to use LocationManager class to get the speed, but when I tried LocationManager a new problem occured. The location manager NetworkProvider is not working, here is a thread with the problem http://code.google.com/p/android/issues/detail?id=57707 . So what is the best way to get the speed of movement. I tried calculating it distance/time but it is not accurate..
-
1check this http://stackoverflow.com/questions/4811920/why-getspeed-always-return-0-on-android – Paulo Roberto Rosa Nov 08 '13 at 12:01
-
The point is that I get coordinates each 15sec, and if you turn left or right while driving the distance that you have passed is not the distance between the 2 points from location manager.. aslo the location client is not always acurate and in places with low signal may have less accuracy and calculate very wrong distance like 300km/h.. – Radoslav Ignatov Nov 08 '13 at 12:29
2 Answers
The only sensor that delivers speed is GPS.
Wlan and GSm cell Tower locatining cannot deliver speed.
If you need speed, you have to make sure that GPS is used exlusivley as Location Provider. You cannot use NetworkProvider for that task.
If speed is an important requirement, which has higher priority than battery consumption you have to stay with GPS Provider only. You have to avoid the fused location provider.
Its technically not possible to have speed without GPS.

- 28,470
- 6
- 53
- 83
-
2The question is referring to Fused Locations provider, which only allows for four criteria based on power consumption; you don't get the opportunity to request specific providers (e.g. GPS only). Are you saying the OP needs to ditch Fused Locations? – warbi Feb 13 '14 at 11:07
-
2You can get speed only with GPS Provider. If speed is an important requirement, which has higher priority than battery consumption you have to stay with GPS Provider only. You have to avoid the fused location provider. – AlexWien Feb 13 '14 at 14:52
I also encountered this problem when I was using Google Play Location API, 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.
Even if you use the locationManager to get the speed if you are not connected to the gps, your getSpeed will still return 0.

- 284
- 3
- 18