I’m using Processing for Android and my app is almost finished. However, Processing for Android doesn’t adapt to phone orientation, which I want to implement. It reads Accelerometer values and I’ve been able to roughly determine the orientation through this simple algorhitm:
if (y > 7)
{
o = UPRIGHT;
}
else if (y < -7)
{
o = UPSIDEDOWN;
}
else if (x > 7)
{
o = TURNLEFT;
}
else
{
o = TURNRIGHT;
}
It’s not flawless, so I’m wondering if there’s a better solution.
Is there a way to poll Android for the current phone UI orientation? Is there a more stable value than 7 (which I chose kind of arbitrarily)?
By monitoring for the following configuration change on orientation, based on the
AndroidManifest.xml, for example, assuming that activity is calledmyActivity, then the following would suffice:And from the
myActivityclass, handle it with this: