Is there any reason why you cannot use the following code ?

if (getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT) {
    //portrait
} ....


On Dec 18, 7:50 pm, 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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to