3

is it possible to detect a speed of a car using GPS or accelerometer in android phone ?

can anyone give me the road map to implement this ?

Hunt
  • 8,215
  • 28
  • 116
  • 256

1 Answers1

6

Yes, it's possible using GPS via object of Location class. There is getSpeed() method in this class.

It's very easy to find code of getting location. Check this link for example.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
  • 1
    so that means , if a car is running at X speed then i will able to detect at what speed it is running using getSpeed() ? – Hunt Dec 21 '10 at 08:18
  • 1
    Yes. Speed returns in meters/second. – Sergey Glotov Dec 21 '10 at 08:24
  • Okay and to access the direction i.e. left , right and reverse ? do i need to use accelerometer ? – Hunt Dec 21 '10 at 08:38
  • With GPS you may get the bearing in degrees via method `getBearing()` of `Location` object. May be better to use accelerometer for this. – Sergey Glotov Dec 21 '10 at 09:14
  • with getSpeed() is not returning correct I have tested any other way by which we can get the speed of vechile...... – Sumant Dec 13 '12 at 09:25