Detect Small Movements on Device Using Accelerometer

Put your problem here if it does not fit any of the other categories.

Detect Small Movements on Device Using Accelerometer

Postby auser12 » Sat Feb 25, 2012 8:01 am

Hi, I was wondering if it is possible to detect if the android device has moved slightly in one direction and to measure the distance that it moved. I assume one would have to use the accelerometer for this, but I have no clue how to do it, or if it's even possible. Could someone please show me an example of how this is done? Thanks for your help.
auser12
Freshman
Freshman
 
Posts: 8
Joined: Sun Feb 05, 2012 12:38 am

Top

Re: Detect Small Movements on Device Using Accelerometer

Postby Phyll » Sat Feb 25, 2012 12:15 pm

Hi auser12,

Here is an example of rolling some balls using the accelerometers:

http://www.edumobile.org/android/androi ... r-example/

Here's another one that just shows you the x,y,z values:

http://webhole.net/2011/08/20/android-s ... -tutorial/

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Detect Small Movements on Device Using Accelerometer

Postby auser12 » Sat Feb 25, 2012 6:20 pm

This is a great example! Is there one where the balls move if I move the device left or right, not just tilt it?
auser12
Freshman
Freshman
 
Posts: 8
Joined: Sun Feb 05, 2012 12:38 am

Re: Detect Small Movements on Device Using Accelerometer

Postby Phyll » Sat Feb 25, 2012 7:19 pm

Hi auser12,

I should think that any x movement of the sensors would make them move. I would have to study the calculations to see how big a part gravity plays in them but I imagine it could be removed if necessary. Did you try making this one work in an emulator or your phone yet?

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Detect Small Movements on Device Using Accelerometer

Postby nuetronprotron » Mon Mar 05, 2012 1:43 pm

Hi auser12,
I think it purely depends upon how u want to implement by using those values from accelerometer and with calculations around that values in seperate thread to draw on surfaceview
nuetronprotron
Developer
Developer
 
Posts: 37
Joined: Tue Jan 10, 2012 10:22 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 18 guests