title: Activity orientation changes automatically on Android
body: <p>I'm developing a mobile application based on Android with <code>minSdkVersion=15</code>. I would like to support both orientations for tablets and only portrait for smartphones. Everything works like a charm but I'm experiencing a little bug that is driving me crazy.
  When smartphone is in landscape mode and I try to trigger a new Activity, it opens in landscape mode for a while and then autorotates to portrait.
  Each one of my activities extend a GeneralActivity class:</p>
  
  <pre><code>public class GeneralActivity extends Activity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // If smartphone lock orientation to portrait
          if (!Helper.isTablet(this.getApplicationContext())){
              this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
          }
      }
  }
  </code></pre>
  
  <p>I detect tablets with this function:</p>
  
  <pre><code>public class Helper {
      public static boolean isTablet(Context context){
          Configuration config = context.getResources().getConfiguration()
          return config.smallestScreenWidthDp &gt;= 600;
      }
  }
  </code></pre>
  
  <p>I choose not to specify <code>android:screenOrientation</code> inside Manifest.xml because in that way I'm able to support all interface orientation for tablets.
  Am I missing something?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I decided to apply the best practice suggested in the answer by Jonathan, but the issue I described is still here. Here's my repo on github: <a href="https://github.com/giacmarangoni/Android-Orientation-Test" rel="noreferrer">https://github.com/giacmarangoni/Android-Orientation-Test</a></p>