Wednesday, December 12, 2012

Re: [android-developers] Re: onConfigurationChanged() is not called when flipping between landscape and reverse landscape?

Hi Dianne, your answer isn't good enough. 
On flipping, the activity isn't informed through onConfigurationChanged (since Honeycomb, I suppose). This saves an unnecessary onSurfaceChange, texture loading, etc. Cool.

But in that case sensor manager too must provide values as in previous orientation. 
Unfortunately it is mangled in accordance to the new orientation.
In NDK, raw sensor vectors aren't officially available in sensor.h.

We use remapCoordinateSystem()[1] when away from default orientation.

We call this on config change to remember the new orientation and compensate for sensor value mangling. 
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation()

Even without JNI such a call must be avoided except on config change event.

It is a overkill to (JNI-)call that on each frame just because the framework hides it from the activity but uses the new orientation in sensor value mangling. 

Framework must inform the activity of the change if it chooses to alter sensor values by the new (flipped) orientation. 

Thanks,
RS
[1] http://developer.android.com/reference/android/hardware/SensorManager.html#remapCoordinateSystem(float[], int, int, float[])
ps: This is specific to flip... there is no switch between landscape<->portrait but just flipped as in landscape to reverse-landscape or portrait to reverse-portrait.

On Friday, June 15, 2012 2:44:55 AM UTC+1, Dianne Hackborn wrote:
This is simply not a configuration change.  There is no notification the platform provides for when it does this, because it is invisible to the environment the app is in.

On Thu, Jun 14, 2012 at 4:36 PM, Farmer <duanx...@gmail.com> wrote:
Thanks guys for your reply!

I tried to set android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize",
but it didn't help.

To Hoang, I can understand that Configuration does not change when I flip the phone. Actually I am calling getRotation() to decide
current display rotation. The thing is that I need a trigger to call the method when orientation is changing between landscape and
reverse landscape. And onConfigurationChanged() is my first thought. Any idea?

On Friday, June 8, 2012 1:26:08 AM UTC+8, Hoang DN wrote:
Hi guy,

In your case, actually, Configuration did not change, therefore the
method onConfigurationChanged() won't be called.
If you want handle this event, you can use
android.view.Display.getRotation(). The returned value may be
Surface.ROTATION_0 (no rotation), Surface.ROTATION_90,
Surface.ROTATION_180, or Surface.ROTATION_270.

Hope this useful for you. Good luck!


Br,
hoangdn

On 7 Tháng Sáu, 23:49, Farmer <duanxiao...@gmail.com> wrote:
> Hi there,
>
> On ICS, when I flip the phone between landscape and reverse landscape,
> it seems onConfigurationChanged() won't be called. How can I get
> notified when such event happens, or did I miss anything here?
>
> Thanks in advance!
>
> best,
> duanxiaotao

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



--
Dianne Hackborn
Android framework engineer
hac...@android.com

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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment