Home

FLAGACTIVITYNEWTASK

FLAGACTIVITYNEWTASK, more commonly known as Intent.FLAG_ACTIVITY_NEW_TASK, is an Android Intent flag that directs the system to start the target activity in a new task on the device’s activity back stack. A task is a collection of activities that users interact with as a unit, with the launched activity becoming the root of that new task.

Value and usage context: The flag is defined in android.content.Intent and is typically used when starting an

Behavior and interaction with task management: With NEW_TASK, the launched activity starts in a separate task,

Usage considerations: Using NEW_TASK can improve isolation of workflows or support specific navigation patterns, such as

See also: related intent flags for task and back stack management, including FLAG_ACTIVITY_MULTIPLE_TASK and FLAG_ACTIVITY_CLEAR_TASK.

activity
from
a
non-activity
context,
such
as
a
Service,
BroadcastReceiver,
or
content
provider.
When
this
flag
is
set,
the
system
creates
a
new
task
for
the
started
activity
rather
than
placing
it
on
top
of
the
current
task.
Without
this
flag,
attempting
to
start
an
activity
from
outside
an
Activity
context
can
result
in
an
error.
and
its
back
stack
is
independent
of
the
caller’s
task.
The
exact
behavior
can
be
influenced
by
other
manifest
attributes
and
flags,
such
as
taskAffinity,
launchMode
(for
example,
singleTask
or
singleInstance),
and
additional
flags
like
FLAG_ACTIVITY_MULTIPLE_TASK,
which
allows
multiple
tasks
for
the
same
affinity.
In
some
situations,
the
system
may
reuse
an
existing
task,
but
NEW_TASK
primarily
ensures
the
activity
is
started
in
a
new,
separate
task
by
default.
opening
an
activity
from
a
notification
or
from
a
background
component.
However,
it
can
also
complicate
back
navigation
if
overused
or
combined
with
other
flags,
so
it
should
be
employed
when
a
separate
task
boundary
is
desirable.