0

How do I track the direction of a motion in Android ?
Think WiiMote, it can track what direction you move it (not talking about the IR lamps), is it possible to do similar in android, if so, how?

Some basic code in either Java or B4A is appreciated, but it's enough if you tell me the logic and maths on how to calculate the direction of movement.

Adam
  • 81
  • 3
  • 7

1 Answers1

0

You have to use accelerometer for this.

I've seen code using accelerometer in here:

http://www.hascode.com/2010/04/sensor-fun-using-the-accelerometer-on-android/

Other stuff about sensors: http://developer.android.com/reference/android/hardware/Sensor.html

Mateusz
  • 2,287
  • 20
  • 28
  • Yes, I know how to use the accelerometer, but the only way to use it as far as I know is either tilting the phone or shaking. What I want to do is moving the phone. Like for example: There is a ball on the screen, I move my phone to the right and the ball moves to the right. I can move a ball with tilt, and I've experimented with shake events, but I can't figure out how to move the phone to move stuff. This may sound impractical, but my idea involves more than this. Only need help with this part tho. – Adam Oct 18 '11 at 17:01
  • Sorry so I don't have good idea for solving your problem. I think it is just impossible because of how accelerometer works but as alway some people say things are impossible but someone can find a way to do it so keep searching. – Mateusz Oct 19 '11 at 21:09