You want to use TYPE_MAGNETIC_FIELD this way, instead of GRAVITY.  GRAVITY I 
haven't seen before but the accelerometer is actually a gravity sensor, so 
I'm wondering if its the same data for each?

Also down the line you will want to minimize the allocations in methods like 
this especially if they're getting called many times per second.  Not sure 
if using System.arraycopy from event.values to your temporary array will 
give a ton of performance over cloning; I haven't timed it, but things like 
that can sometimes make a big difference.  Same with allocating the matrix 
of float[16] for instance on each call, definitely want to avoid that.

I'm going to guess that with MAGNETIC_FIELD+ACCELEROMETER this should work 
okay.  Just know that the values WILL get wacky as you approach certain 
pitches.

   
On Wednesday, July 20, 2011 12:08:06 AM UTC-4, Nathan wrote:
>
> You are getting gravity from the accelerometer and magnetic field from 
> gravity. 
>
>                 case Sensor.TYPE_ACCELEROMETER: { 
>                     mGravity = event.values.clone(); 
>                     break; 
>                 } 
>                 case Sensor.TYPE_GRAVITY: { 
>                     mGeomagneticField = event.values.clone(); 
>                     break; 
>                 } 
>
> But then again, the sample I cited is getting gravity from the 
> accelerometer also, so it seems wrong. 
>
> Nathan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to