One app, two windows, but not split screen


Is it possible for an app to have two "windows"(?) (with separate contents) you can switch in between? (like on desktop you can have two browser windows.)

My research so far only brought up how that works with split-screen and multi-window, but that would *share* the screen, while I am thinking/asking about a regularily sized window.

1
Oct 20 at 6:18 AM
User Avatarcriztovyl
#android

Accepted Answer

Yes. Each "window" is a separate task, and every task gets its own card in Recents, so the user switches between them the same way they switch between apps. Start the activity with FLAG_ACTIVITY_NEW_DOCUMENT, and add FLAG_ACTIVITY_MULTIPLE_TASK if you want a new one every time

val intent = Intent(this, SecondWindowActivity::class.java).apply {
    addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
}
startActivity(intent)

Or just set it in the manifest

<activity
    android:name=".SecondWindowActivity"
    android:documentLaunchMode="always" />

The activity has to keep launchMode="standard" (that is the default). Google Drive uses this to show each open document as its own task in Recents.

Read more here: https://developer.android.com/guide/components/activities/recents

User AvatarEmmanuel Obiechina Ikenna
Oct 20 at 7:10 AM
2