Software Engineering & Digital Products for Global Enterprises since 2006
CMMi Level 3SOC 2ISO 27001
Menu
View all services
Staff Augmentation
Embed senior engineers in your team within weeks.
Dedicated Teams
A ring-fenced squad with PM, leads, and engineers.
Build-Operate-Transfer
We hire, run, and transfer the team to you.
Contract-to-Hire
Try the talent. Convert when you're ready.
ForceHQ
Skill testing, interviews and ranking — powered by AI.
RoboRingo
Build, deploy and monitor voice agents without code.
MailGovern
Policy, retention and compliance for enterprise email.
Vishing
Test and train staff against AI-driven voice attacks.
CyberForceHQ
Continuous, adaptive security training for every team.
IDS Load Balancer
Built for Multi Instance InDesign Server, to distribute jobs.
AutoVAPT.ai
AI agent for continuous, automated vulnerability and penetration testing.
Salesforce + InDesign Connector
Bridge Salesforce data into InDesign to design print catalogues at scale.
View all solutions
Banking, Financial Services & Insurance
Cloud, digital and legacy modernisation across financial entities.
Healthcare
Clinical platforms, patient engagement, and connected medical devices.
Pharma & Life Sciences
Trial systems, regulatory data, and field-force enablement.
Professional Services & Education
Workflow automation, learning platforms, and consulting tooling.
Media & Entertainment
AI video processing, OTT platforms, and content workflows.
Technology & SaaS
Product engineering, integrations, and scale for tech companies.
Retail & eCommerce
Shopify, print catalogues, web-to-print, and order automation.
View all industries
Blog
Engineering notes, opinions, and field reports.
Case Studies
How clients shipped — outcomes, stack, lessons.
White Papers
Deep-dives on AI, talent models, and platforms.
Portfolio
Selected work across industries.
View all resources
About Us
Who we are, our story, and what drives us.
Co-Innovation
How we partner to build new products together.
Careers
Open roles and what it's like to work here.
News
Press, announcements, and industry updates.
Leadership
The people steering MetaDesign.
Locations
Gurugram, Brisbane, Detroit and beyond.
Contact Us
Talk to sales, hiring, or partnerships.
Request TalentStart a Project
Mobile Development

Android Launch Mode: Understanding Activity Behavior in Mobile App Development

AG
Amit Gupta
CEO
September 13, 2022
8 min read
Android Launch Mode: Understanding Activity Behavior in Mobile App Development — Mobile Development | MetaDesign Solutions

What Are Android Launch Modes?

Launch mode is an Android OS command that determines how an activity should be started. It specifies how every new action should be linked to the existing task. In Android, an app can have multiple tasks, and activities can behave differently based on their launch mode.

There are four launch modes for activity:

  • Standard
  • SingleTop
  • SingleTask
  • SingleInstance

Understanding the Back Stack

The back stack is a representation of how each new activity in a task adds an item to the stack. When the user presses or gestures Back, the current activity is destroyed, and the previous activity resumes. Understanding the back stack is fundamental to mastering Android launch modes.

1. Standard Launch Mode

This is the default launch mode of an activity. If you don't set any launch mode for your activity, it will use the standard mode by default. This mode creates a new instance of the activity every time, even if the activity instance is already present in the task.

For example, if we have activities A, B, C, and D, and launch activity B again:

Before: A → B → C → D

After: A → B → C → D → B

A new instance of B is created again, resulting in multiple instances on the stack.

<activity android:launchMode="standard" />

2. SingleTop Launch Mode

If an instance of an activity already exists at the top of the current task, a new instance will not be created, and the Android system will route the intent information through the onNewIntent() method. If the instance is not at the top, a new instance will be created.

Example 1 — C is not at top: A → B → C → D → launching C creates: A → B → C → D → C

Example 2 — C is at top: A → B → C → D → C → launching C reuses: A → B → C → D → C (onNewIntent called)

<activity android:launchMode="singleTop" />

3. SingleTask Launch Mode

An activity declared with launch mode as singleTask can have only one instance in the system (like a singleton). If the activity instance is not present, a new instance will be created. If the instance is already present, the onNewIntent() method will receive the callback.

Example: Stack A → B → C, launching D (singleTask) gives: A → B → C → D. Then launching B (singleTask) gives: A → B — with C and D destroyed.

This behavior is particularly useful when you want to ensure certain activities, like the root activity, are only created once.

<activity android:launchMode="singleTask" />

Transform Your Publishing Workflow

Our experts can help you build scalable, API-driven publishing systems tailored to your business.

Book a free consultation

4. SingleInstance Launch Mode

This is similar to singleTask, except that no other activities will be created in the same task. If another activity is launched from a singleInstance activity, a new task will automatically be created for that new activity.

Case 1: Activities A → B → C exist, and D has singleInstance. Launching D creates:

  • Task 1: A → B → C
  • Task 2: D

Case 2: Launching D again routes intent through onNewIntent() — no new instance is created.

<activity android:launchMode="singleInstance" />

Task Affinity and Multiple Tasks

In Android, the taskAffinity attribute allows you to assign a specific affinity to an activity, which determines in which task the activity should reside. By setting taskAffinity, Android developers can control which activities share the same task, helping create a better user experience when navigating through the app.

When a new activity is launched, the taskAffinity value is checked to determine whether the new activity should be part of an existing task or if a new task should be created. This feature is particularly important when dealing with singleTask and singleInstance launch modes.

State Restoration and Navigation

A key consideration for Android developers is how to handle state restoration when navigating between different tasks. When activities are recreated or brought back to the foreground, developers need to manage how the state is restored to provide a seamless user experience.

By using launch modes like singleTask and singleInstance, you can ensure that only a single instance of an activity exists across tasks, reducing redundancy and improving app efficiency. The onNewIntent() method plays a crucial role in restoring the state of an activity when it is relaunched.

Conclusion

Understanding Android launch modes is crucial for managing activity behavior and navigation in mobile app development. By choosing the right launch mode — standard, singleTop, singleTask, or singleInstance — developers can control how activities are instantiated and how they interact with the back stack, leading to optimized memory usage and a better user experience.

FAQ

Frequently Asked Questions

Common questions about this topic, answered by our engineering team.

The four launch modes are Standard (creates new instance every time), SingleTop (reuses instance if at top of stack), SingleTask (only one instance in the system, destroys activities above it), and SingleInstance (only activity in its task, creating new tasks for other activities).

The default launch mode is Standard. If no launch mode is explicitly set for an activity, it uses Standard mode, which creates a new instance of the activity every time it is launched, regardless of whether an instance already exists in the task.

Use SingleTask when you want to ensure only one instance of an activity exists in the system, such as for root/home activities. When the activity is relaunched, all activities above it in the stack are destroyed and onNewIntent() is called.

TaskAffinity is an attribute that determines which task an activity should belong to. By setting taskAffinity, developers control which activities share the same task, which is especially important when using singleTask and singleInstance launch modes for proper navigation management.

Use singleTask for login screens — it ensures only one instance exists and clears the back stack above it when re-launched. This prevents users from navigating back to authenticated screens after logout. Combine with FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_NEW_TASK for complete stack management during authentication state transitions.

Discussion

Join the Conversation

Ready when you are

Let's build something great together.

A 30-minute call with a principal engineer. We'll listen, sketch, and tell you whether we're the right partner — even if the answer is no.

Talk to a strategist
Need help with your project? Let's talk.
Book a call