Hi Fabio, This is for a camera app, and the activity is set to remain in landscape mode all the time. So if I want to find out which way the phone is oriented, I need to use the sensors, as the configuration will always report that I'm in landscape mode,
Thanks On Dec 18, 6:51 pm, Fabio <piuc...@gmail.com> wrote: > 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 <mar...@gmail.com> 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en