title: multiple layout files and back stack navigation
body: <p>We have an application with three activities Main List and Detail min SDK 19 and developed with SDK 25 tools. We have a password log on screen in the Main activity. When we use the onBackPressed which is fired by the device back button. To learn how to manage multiple screen sizes we wrote a test app that has an additionl layout-sw600dp for each activity. When navigating the app with Nexus 5X emulator the navigation runs as designed. Then when navigating with Nexus 7 emulator we need to double click the device back button to fire the method. I was able to fix this with the code posted below. Could we have an explanation why when the layout-sw600dp file was added that the code needed to be adjusted. We are guessing that the code is removing the List activity from the back stack.
  Manifest</p>
  
  <pre><code>    &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".MainActivity"
          android:excludeFromRecents="true"
          android:launchMode="singleTask"&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=".ListActivity"
          android:launchMode="singleTask"&gt;
      &lt;/activity&gt;
      &lt;activity android:name=".DetailsActivity"
          android:launchMode="singleTask"&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>List Intent to go to Detail</p>
  
  <pre><code>    private void addListenerOnButtonMove() {
      btnMove.setOnClickListener( new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent intent = new Intent( ListActivity.this, DetailsActivity.class );
              intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
              /* CODE above is necessary when using additional ACTIVITY sw600dp files */
              //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
              startActivity( intent );
          }
      } );
  }
  </code></pre>
  
  <p>Detail Intent to go to Main</p>
  
  <pre><code>    public void onBackPressed(){
      Toast.makeText(DetailsActivity.this,"Details Was Clicked",Toast.LENGTH_LONG).show();
      Intent intent = new Intent( DetailsActivity.this, MainActivity.class );
      startActivity( intent );
  }
  </code></pre>
  
  <p>Main to clear the app</p>
  
  <pre><code>    public void onBackPressed(){
      Intent startMain = new Intent(Intent.ACTION_MAIN);
      startMain.addCategory(Intent.CATEGORY_HOME);
      startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      startMain.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
      /* This code needs 2 clicks to work in Emulator Tablet 7 inch*/
      /* If you navigate in the app then the code fires with FIRST CLICK */
      //startMain.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
      //startMain.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
      startActivity(startMain);
  }
  </code></pre>
  
  <p>So our question is why do we need to add this line of code when layout-sw600dp is added but not needed with the base layout</p>
  
  <pre><code>intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
  </code></pre>