title: Automatic change of activity : Landscape and portrait mode in Android
body: <p>I have two activities in my Android app. On click I can move from one activity to another, back and forth. But when I am changing from landscape to portrait mode and vice versa, my activity is getting changed automatically which I did not expect. I expect it to remain on the same activity even if it is changed to portrait or landscape mode. So what might be the problem?</p>
  
  <p><strong>Update</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.dmacs.myapplication"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/icon1"
          android:label="@string/app_name"
          android:logo="@drawable/icon2"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
  
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name"
              android:theme="@style/AppTheme.NoActionBar"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
  
          &lt;activity android:name=".second_main"&gt;
          &lt;/activity&gt;&lt;!-- ATTENTION: This was auto-generated to add Google Play services to your project for
       App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information. --&gt;
          &lt;meta-data
              android:name="com.google.android.gms.version"
              android:value="@integer/google_play_services_version" /&gt;
  
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>