Detect Movement Accurately using Accelerometer in Android

后端 未结 3 2081
小蘑菇
小蘑菇 2021-02-03 13:10

I am implementing a demo TIMER, with Vibration ( at a particular condition ), When I press start my timer starts running.. and when I stop it using stop button, it simply stops.

3条回答
  •  一向
    一向 (楼主)
    2021-02-03 13:26

    Two suggestions, and one thought:

    1. For consistent behaviour, you should look at the length of the event.values vector, i.e. Math.sqrt(x*x+y*y+z*z), rather than the individual values. Mathematically, it's Math.sqrt(x*x+y*y+z*z) that's independent of your co-ordinate system, i.e. how the device is oriented relative to the ground etc, whereas the individual numbers x, y, z aren't.
    2. Your current app looks for changes in acceleration. Instead, I think you should just look for high acceleration, i.e. large values of Math.sqrt(x*x+y*y+z*z).
    3. I recently wrote this answer about using accelerometers for a pedometer, and I think you might find it interesting.

提交回复
热议问题