Home

launchMode

LaunchMode is an attribute in Android development that determines how an activity is launched and how its instance is managed within tasks. It is declared in the AndroidManifest.xml on an activity element using android:launchMode. The choice of launchMode affects whether new instances are created, how intents are delivered, and how the activity participates in the task back stack.

The standard mode is the default. It creates a new instance of the activity whenever it is

singleTask ensures that only one instance of the activity exists in the system. If an instance already

singleInstance places the activity in its own dedicated task, which contains only that activity. No other activities

LaunchMode interacts with features such as taskAffinity and back-stack handling, and it influences how deep links

launched,
allowing
multiple
copies
to
exist
in
the
system
and
in
different
tasks
as
needed.
singleTop
is
used
when
the
activity
is
already
at
the
top
of
the
current
task;
in
this
case,
no
new
instance
is
created,
and
the
existing
one
receives
the
new
intent
via
onNewIntent
instead
of
creating
a
new
object.
If
the
activity
is
not
at
the
top,
a
new
instance
is
created
as
usual.
exists
in
any
task,
that
task
is
brought
to
the
foreground
and
the
existing
instance
becomes
the
root
of
its
task;
onNewIntent
is
called
for
the
new
launch.
This
mode
is
intended
for
activities
that
should
manage
a
separate
task
and
should
not
be
duplicated.
from
the
same
application
share
the
task.
This
mode
is
rarely
needed
and
is
typically
used
for
components
that
must
run
in
isolation.
and
launcher
launches
are
resolved.
Developers
should
choose
the
mode
based
on
desired
task
structure
and
instance
management.