开发者

Detect car acceleration in Android app?

开发者 https://www.devze.com 2023-01-02 22:43 出处:网络
I want to incorporate some Accelerometer code into a Android application im working and want to see if this is possible. Basically what I need is for the code to detect car acceleration motion. I am n

I want to incorporate some Accelerometer code into a Android application im working and want to see if this is possible. Basically what I need is for the code to detect car acceleration motion. I am not wanting to determine speed with the code but just distinguish if the phone is in a car and has accelerated motion (Hence the car is moving for the first time). I have gone through many different accelerometer applications to see if this motion produces a viable profile to go off of and it appears it does. Just looking for something that popups a "Hello World" dialog when it detects your in the car and its moving for the first time down the street. Any help would be appreciated and a simple yes or no its possible would work. I would also be interested in compensating anyone that is ca开发者_Python百科pable of doing this as well. I need this done like yesterday so please let me know.

Thank You,

JTW


Basically what I need is for the code to detect car acceleration motion.

As others have noted, there is no such thing as "car acceleration". There is only acceleration. Acceleration, as a concept in physics, can come from everything from a car to the device being shaken.

So, for example, here is some code that detects a device being shaken.

So, the question then becomes: can you come up with an acceleration value that is definitively from a car in motion? I suspect the answer is no, for most cars. For example, this site indicates that a 2008 Aston Martin demonstrates an acceleration of 6.5 meters/second^2. The force of gravity is greater (9.8 meters/second^2). My shake code will only register a shake at around 12 meters/second^2 -- less than that, and simple movements will be considered a shake.

As another answer suggests, you are probably better served using GPS.

If, on the other hand, you can supply me with a 2008 Aston Martin for testing, I'd be happy to run some accelerometer experiments... :-)


Yes. If by moving the car, the device moves :P

http://stuffthathappens.com/blog/2009/03/15/android-accelerometer/

But probably, it would be better to combine it with GPS.

http://www.devx.com/wireless/Article/43005/1954

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号