Technical review · 2026-10-13. The 2019 sequences remain historical examples. Task selection, affinity, and Recents behavior were checked against AOSP android-9.0.0_r1 and android-16.0.0_r1; Android 12 (API 31) singleInstancePerTask is added below. The old records lack a complete device build identifier, and no device rerun was performed for this review.
Android Activities have several important launch modes: standard, singleTop, singleTask, and singleInstance. Plenty of articles explain these modes. I wrote a small demo to show how they change the arrangement of activities in tasks. The newer singleInstancePerTask mode is covered afterward.
Ordinary navigation within a task is commonly LIFO. Below, A -> B denotes the sequence of launch actions; task contents are listed top first. Keep an eye on the task contents after each action; following the changes makes the differences easier to see. Repeating a launch action does not necessarily create an instance. A Task is not a process or necessarily one visible Recents card.
I put the demo on GitHub too: AndroidLunchModeTest. The reviewed snapshot is eaa1f987e332e0f85187a911ad9ae01cd20fff05, using compile/target SDK 29 and min SDK 26. Its package is com.example.lunchmodetest, whereas the historical sequences below retain com.example.launchmodetest.
Check all navigation targets for each case. In the snapshot, MainActivity.startSingleTopActivity launches SingleTaskActivity, and StandardActivity launches SingleInstanceWithAffinityActivity by default. Changing one target does not implement every sequence. The WithAffinity classes actually use empty affinity; SingleTopWithAffinityActivity does not even declare singleTop. Class names are not configuration evidence. The sample code was inspected for this review; the project was not modified or compiled.
The explanations assume the same user, ordinary foreground Activity launches, and no extra Intent flags unless stated. Updating the old project to target SDK 31+ also requires explicit android:exported for components with intent filters; use true for the Launcher entry.
standard Mode
The default mode creates a new instance in these examples, which launch from an Activity without additional Intent flags that change reuse behavior. The manifest mode alone does not describe every possible launch.
If the selected task already has the target Activity instance at its top, that instance receives onNewIntent(). An instance lower in the same task is not reused by singleTop alone. “Top” means the selected task’s top, not a single global stack for the device.
//SingleTopActivity receives a new intent; no new instance is created.
singleTask Mode
1
android:launchMode="singleTask"
The system searches for a reusable task under the launch conditions, beyond just the caller’s current task. It creates a task if no suitable one is found.
If the selected task contains the target instance, the system delivers the new intent to it and removes activities above it. Otherwise, a new instance may be added to the selected task with matching affinity.
In the original example, omitting taskAffinity inherits the app’s default affinity, which can select an existing task. It does not mean “always stay in the current task,” nor does singleTask unconditionally require the target to be the root.
The old “Without Affinity” label means no explicit attribute, so default affinity applies. The following preserves the original sequence and task contents.
//SingleTaskActivity receives a new intent; StandardActivity above it is removed.
Test 2: singleTask with empty affinity
Despite its name, SingleTaskWithAffinity declares android:taskAffinity="": no affinity. It cannot match an ordinary task through shared affinity, so the first launch creates a task when no reusable target task exists. Later launches can still match the target component and reuse its task; an empty affinity does not force a new task every time.
These configurations select different Tasks in the example. A Task is not the old framework ActivityStack container, so this does not imply creation of a new ActivityStack.
A normal launch of StandardActivity from SingleTaskWithAffinity can place it in the same task despite a different default affinity.
Launching SingleTaskWithAffinity again from another task can reuse its task and instance, removing activities above it.
A separate Recents card depends on Recents management, exclusion flags, and system behavior, not just the class name or empty affinity.
singleInstance Mode
1
android:launchMode="singleInstance"
The singleInstance task contains only that Activity. Other activities it starts must use another task. The system looks for an existing instance of the same target component for the same user; this is not a Java singleton shared across users, work profiles, or process death.
My notes about a task being absent or present in “multitasking” describe the Recents cards I saw, not whether the Task exists. They are historical UI observations, not guarantees of the launch mode.
Test 1: singleInstance with default affinity
No explicit taskAffinity is supplied, so the default applies. StandardActivity returning to Task 0 below is this example’s task-selection result; another launch can select a different existing task or create one.
//Task 1 contents (historical observation: no separate Recents card) com.example.launchmodetest/.SingleInstanceActivity //Task 0 contents com.example.launchmodetest/.StandardActivity com.example.launchmodetest/.StandardActivity com.example.launchmodetest/.StandardActivity com.example.launchmodetest/.MainActivity
singleInstance Summary
singleInstance owns a dedicated task, but does not guarantee that its Recents card is hidden.
Reuse matches the user and target component, allowing delivery of onNewIntent. Configuration changes or process recreation can still create a new client-side Activity object.
Activities started from it use another task selected by the system, not necessarily “the previous task.”
For example, Android 9 RecentTasks.findRemoveIndexForAddTask and Android 16 RecentTasks compare nonempty affinity, base intents, and other conditions when deduplicating/trimming ordinary task entries. Shared affinity can therefore affect cards, but the old notes do not establish the precise cause of each device observation.
Test 2: singleInstance with empty affinity
Here too, the old “With Affinity” label refers to android:taskAffinity="", meaning no affinity. The separate Recents card is retained as a historical observation; empty affinity does not disable singleInstance reuse.
//Task 1 contents:(historical observation: a Recents card is shown) com.example.launchmodetest/.SingleInstanceWithAffinityActivity //Task 0 contents: com.example.launchmodetest/.StandardActivity com.example.launchmodetest/.StandardActivity com.example.launchmodetest/.StandardActivity com.example.launchmodetest/.MainActivity
Since Android 12: singleInstancePerTask
Android 12 (API 31) added singleInstancePerTask. The Activity must be the task root, with one instance of that component per task; other activities can still join the task.
An ordinary repeat launch can reuse the task and clear activities above the target. Suitable MULTIPLE_TASK or NEW_DOCUMENT launches can create instances of the component in separate tasks. This differs from singleInstance, whose task contains only one Activity. Document modes and flags still interact, so one flag is not an unconditional guarantee of a new instance. The 2019 demo does not implement this mode.
Intent Flags and onNewIntent
Caller flags also affect the outcome. These combinations are particularly relevant to the examples:
Launch option
Effect
SINGLE_TOP
Reuse a target already at the selected task’s top; it does not automatically find it lower down and clear intervening pages
NEW_TASK
Search for or create a task; it does not always create one
CLEAR_TOP
Clear activities above the target; for a standard target without SINGLE_TOP or another reuse condition, the target itself can also be finished and recreated
NEW_TASK + CLEAR_TASK
Clear the selected task’s old contents and make the new Activity its root; this is not an alias for CLEAR_TOP
Reuse does not automatically consume new parameters. The Activity API documents that getIntent() still returns the previous Intent unless updated with setIntent. Process the new parameters in the callback. For example, inside an existing Activity class:
1 2 3 4 5 6
@Override protectedvoidonNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); // Update the page from this Intent, sharing handling with the initial onCreate path. }
This fragment illustrates Intent replacement, not a complete demo. Inspect onCreate/onNewIntent, getTaskId, and task contents before and after each operation to distinguish a new task, a new Activity, and a reused instance receiving another Intent. The original am_new_intent is a historical system event name, not a guaranteed current log tag.
Key Concepts
TaskAffinity
taskAffinity expresses an Activity’s affinity for a task. It participates in task selection and permitted reparenting; it does not force all activities with the same affinity into one task. A normal startActivity call can place activities with different affinities in the caller’s task, and one app can have several tasks.
Configuration
Meaning
No activity taskAffinity attribute
Inherit <application> affinity; the app default is its package name
android:taskAffinity=""
No affinity, commonly represented as null in dumps
NEW_TASK-related searches and allowTaskReparenting use affinity together with component, user, flags, and task state. Affinity grants no permissions and does not make apps share a process. See the activity manifest reference.
These names describe the older AMS container model used by the historical diagrams. They are not unchanged across all Android versions.
ActivityRecord is a server-side Activity record in system_server. One Activity class can have multiple records; a record does not imply that one Java Activity object remains alive forever in the app process.
TaskRecord groups ActivityRecords in a task. Ordinary navigation commonly behaves as LIFO, while clearing, reordering, and cross-task launches change the sequence.
ActivityStack manages TaskRecords; ActivityDisplay groups stacks for a display, coordinated by ActivityStackSupervisor. There is not always one display object, nor a fixed total of Home/App/Recents stacks.
The referenced Gityuan article was published in 2017. Its container relationships help explain the old model; the diagram is not a modern multi-window architecture map.
The next image preserves the original adb shell dumpsys activity containers output. It shows display 0 and numStacks=5, already contradicting a fixed “three stacks” rule. Task 671 contains several ActivityRecords. Task IDs, stack IDs, and PIDs identify different things.
In android-16.0.0_r1, containers include RootWindowContainer, DisplayContent, TaskDisplayArea, Task, and TaskFragment. Task itself extends TaskFragment. Root/leaf tasks, nested Tasks, and embedded activities prevent a mechanical three-level replacement of the old diagram. TaskRecord and ActivityStack are not stable cross-version APIs. Dump commands and formatting also vary; no new device dump was produced for this review.
Activity Types
These are Android 9 WindowConfiguration activity-type constants, not launch modes. For example, type=standard and android:launchMode=”standard” describe different dimensions.
1 2 3 4 5 6 7 8 9 10
/** Activity type is currently not defined. */ publicstaticfinalintACTIVITY_TYPE_UNDEFINED=0; /** Standard activity type. Nothing special about the activity... */ publicstaticfinalintACTIVITY_TYPE_STANDARD=1; /** Home/Launcher activity type. */ publicstaticfinalintACTIVITY_TYPE_HOME=2; /** Recents/Overview activity type. There is only one activity with this type in the system. */ publicstaticfinalintACTIVITY_TYPE_RECENTS=3; /** Assistant activity type. */ publicstaticfinalintACTIVITY_TYPE_ASSISTANT=4;
Android 16 WindowConfiguration additionally defines ACTIVITY_TYPE_DREAM = 5. These framework role classifications are not a way to declare an app as Home, Recents, or Assistant through launchMode.
If you found this useful, please share it. I hope it helps others too.