Following the documentation, you can ask Android to open a given Intent in the adjacent focus window using the FLAG_ACTIVITY_LAUNCH_ADJACENT
.
Example:
Intent intent = new Intent(getActivity(), Browser.class);
intent.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
getActivity().startActivity(intent);
Documentation extract:
When you launch a new activity, you can hint to the system that the new activity should be displayed adjacent to the current one, if possible. To do this, use the intent flag FLAG_ACTIVITY_LAUNCH_ADJACENT. Passing this flag requests the following behavior:
- If the device is in split-screen mode, the system attempts to create the new activity next to the activity that launched it, so the two activities share the screen. The system is not guaranteed to be able to do this, but it makes the activities adjacent if possible.
- If the device is not in split-screen mode, this flag has no effect.
- If a device is in freeform mode and you are launching a new activity, you can specify the new activity's dimensions and screen location by calling ActivityOptions.setLaunchBounds(). This method has no effect if the device is not in multi-window mode.
Note: If you launch an activity within a task stack, the activity replaces the activity on the screen, inheriting all of its multi-window properties. If you want to launch the new activity as a separate window in multi-window mode, you must launch it in a new task stack.