title: How to set different orientation changing settings on phone and tablet?
body: <p>I making an app both for phones and galaxy tab.
  I want to be only portrait mode on phones, and portrait and landscape as well in tabs.</p>
  
  <p>So far i got this code snippet:</p>
  
  <pre><code>        public void onCreate(Bundle savedInstanceState)
          {
              DisplayMetrics dm = new DisplayMetrics();
              getWindowManager().getDefaultDisplay().getMetrics(dm);
  
              int width = dm.widthPixels;
              int height = dm.heightPixels;
  
              if(!(width&gt;=800 &amp;&amp; height&gt;=1280))
              {
                  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
              }
  
  
  
              super.onCreate(savedInstanceState);
              setContentView(R.layout.mylayout);
  
              //... more code below
  </code></pre>
  
  <p>So i just check the screen size and if it is the tablet's 800x1280, i do nothing and orientation change is active. If it is not 800x1280 i do:</p>
  
  <pre><code>setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
  </code></pre>
  
  <p>I thought it will be work fine, but for some random bug, it is not working every time..
  Lets say for about ten times, the orientation just changes to landscape to a second on phones then it changes back to portrait. So a little buggy a little wrong.</p>
  
  <p>Is it another better way to do this?</p>