title: How to change screen orientation, without creating a new activity on android?
body: <p>I do not know if the title is correct, here is what happens.</p>
  
  <p>I have an application which works differently on a phone and on a tablet, on a phone it shows as portrait on a tablet it shows as landscape.</p>
  
  <p>To achieve this I created a class called CoreActivity which is extended by all my activities and does the following:</p>
  
  <pre><code>public class CoreActivity extends Activity {
      protected boolean _landscape = false;
  
      public boolean isPhone() {
          int layoutSize = getScreenLayoutSize();
          return (layoutSize == Configuration.SCREENLAYOUT_SIZE_SMALL || layoutSize == Configuration.SCREENLAYOUT_SIZE_NORMAL);
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (isPhone() &amp;&amp; !_landscape) {
              this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
          } else {
              this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
          }
      }
  
  
      protected int getScreenLayoutSize() {
          return (getResources().getConfiguration().screenLayout &amp; Configuration.SCREENLAYOUT_SIZE_MASK);
      }
  }
  </code></pre>
  
  <p>My problem occurs when I wish to show a screen on a phone setup on landscape mode, to do this I use the following:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      _landscape = true
      super.onCreate(savedInstanceState);
  }
  </code></pre>
  
  <p>The problem is, that on a phone, if the user is holding the phone on portrait mode (as one would, since most of the application is in portrait mode) then the activity gets created and destroyed and then recreated. But if they are holding it on landscape mode, then it is only created once.</p>
  
  <p>My problem occurs because on the onCreate method I launch the threads that load data, and I also show fragments.</p>
  
  <p>Is there a way to avoid this problem? is there a way to launch an activity from the start on portrait mode and not change it, or have it not create twice?</p>
  
  <p>Thanks in advance for any help you can provide</p>