title: How to determine orientation through accelerometer?
body: <p>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: </p>
  
  <pre><code>  if (y &gt; 7)
    {
      o = UPRIGHT;
    }
    else if (y &lt; -7)
    {
      o = UPSIDEDOWN;
    }      
    else if (x &gt; 7)
    {
      o = TURNLEFT;
    }
    else
    {
      o = TURNRIGHT;
    }   
  </code></pre>
  
  <p>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)?</p>