This may a related issue. When using the accelerometer sensor on Droid when
I hold the device with the display plane vertical, like when taking a
picture, the y axis is minus one g, regardless of lanscap or portrait
orientation.

On Dec 18, 2009 10:50 AM, "Mark Wyszomierski" <[email protected]> wrote:

Hi,

I'm trying to detect landscape vs portrait orientation with the
following:

 public void onSensorChanged(SensorEvent event) {
     float pitch = event.values[2];
     if (pitch <= 45 && pitch >= -45) {
        // portrait
     }
     else if (pitch < -45) {
        // landscape
     }
     else if (pitch > 45) {
        // landscape
     }
 }

anyone have something more robust? It works pretty well, except if the
phone is in a landscape orientation, and the user starts to 'flatten'
it out, starts thinking it's in the portrait orientation again,

Thanks

--
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]<android-developers%[email protected]>
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

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