The docs for Android N Developer Preview 1 show that you can use Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT
to request Android activity to start in a separate window (free form) or an adjacent panel (split screen). Sample Google code shows using Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK
Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK
to accomplish this.
This works great if the running activity is a different class than the one that makes the launch.
So, for example, if you have MainActivity
, which has the following code to run a separate instance of itself:
Intent i= new Intent(this, MainActivity.class) .setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i);
then the result is that FLAG_ACTIVITY_LAUNCH_ADJACENT
ignored, and the new activity instance goes into an existing window or panel.
If, however, you trigger any other action (for example, SecondActivity.class
), then FLAG_ACTIVITY_LAUNCH_ADJACENT
works as advertised.
What if you want to allow the user to open two tables, two notebooks or two of them? How can we use FLAG_ACTIVITY_LAUNCH_ADJACENT
to start two instances of the same activity?
source share