title: Android determine screen orientation at runtime
body: <p>Here's a pseudo code to detect screen rotate event, and decide to retain or changes the screen orientation.</p>
  
  <pre><code>public boolean onOrientationChanges(orientation) {
    if(orientation == landscape)
      if(settings.get("lock_orientation"))
        return false;   // Retain portrait mode
      else
        return true; // change to landscape mode
  
    return true; 
  }
  </code></pre>
  
  <p>How do I make similar things in Android?</p>
  
  <p><strong>EDIT:</strong>
  I'm actually looking answer on <strong>Where to handle orientation changes</strong>. I do not want to fix the orientation by adding screenOrientation="portrait". </p>
  
  <p>I need something, similar to onConfigurationChanges(),  where I can handle the orientation, but do no need me to manually redraw the view.</p>