How Do I Launch the Same Activity Into a Separate Window in Android N Multi-Window?
<p>The docs for the Android N Developer Preview 1 indicate that you can use <code>Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT</code> to request that Android launch an activity into a separate window (freeform) or an adjacent pane (split-screen). Google's sample code shows using <code>Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK</code> to accomplish this.</p>

<p>This works fine, if the activity being started is a different class than the one doing the starting.</p>

<p>So, for example, if you have a <code>MainActivity</code> that has the following code to launch a separate instance of itself:</p>

<pre><code>  Intent i=
    new Intent(this, MainActivity.class)
      .setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT |
        Intent.FLAG_ACTIVITY_NEW_TASK);

  startActivity(i);
</code></pre>

<p>then the result is that <code>FLAG_ACTIVITY_LAUNCH_ADJACENT</code> is ignored and the new activity instance goes into the existing window or pane.</p>

<p>If, however, you launch any other activity (e.g., <code>SecondActivity.class</code>), then <code>FLAG_ACTIVITY_LAUNCH_ADJACENT</code> works as advertised.</p>

<p>What if you want to allow the user to open two spreadsheets, two notepads, or two of whatever-it-is from your app? How can we use <code>FLAG_ACTIVITY_LAUNCH_ADJACENT</code> to launch two instances of the same activity?</p>