http://android-developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html

On Wed, Jun 29, 2011 at 10:22 AM, Mike D <[email protected]> wrote:

> Hi guys,
>
> I've been playing around with orientation (especially in relation to
> the real world so finding north is very useful) and started with the
> google api example.
>
> While investigating how to change that so it worked while the phone
> was in landscape I found out that I was using depricated components.
> So now I'm using the acceloromiter and the magnetic field to find the
> orientation which I found in a mixture of examples on the web.
>
> This again works great while in portrain but landscape gives weird
> answers?
>
> I've done some experiments with looking at the different between
> landscape and portrait but can't seem to find out what's going on and
> how to correct the app to allow me to switch between portrain and
> landscape on the fly.
>
> I don't think it's quite as simple and minusing 90 degrees but I'm
> willing to be wrong.
>
> Here's my SensorListener onSensorChanged
>
> int type = event.sensor.getType();
>                float[] data;
>                if (type == Sensor.TYPE_ACCELEROMETER) {
>                        data = mGData;
>                } else if (type == Sensor.TYPE_MAGNETIC_FIELD) {
>                        data = mMData;
>                }
>
>               for (int i=0 ; i<3 ; i++){
>                        data[i] = event.values[i];
>                }
>
>                SensorManager.getRotationMatrix(mR, mI, mGData,
> mMData);
>
>                SensorManager.getOrientation(mR, mOrientation);
>                float incl = SensorManager.getInclination(mI);
>                String endl = System.getProperty("line.separator");
>                if (mCount++ > 50) {
>                        final float rad2deg = (float)(180.0f/Math.PI);
>                        mCount = 0;
>                        txZ.setText("Azimuth: " +
> (int)(mOrientation[0]*rad2deg) + "
> degrees" + endl +
>                                        "Pitch: " +
> (int)(mOrientation[1]*rad2deg) + " degrees" + endl +
>                                        "Roll: " +
> (int)(mOrientation[2]*rad2deg) + " degrees" + endl +
>                                        "incl: "+ (int)(incl*rad2deg));
>                }
>
> Many Thanks
> Michael
>
> --
> 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
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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