Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Activity launch policy
Stay organized with collections
Save and categorize content based on your preferences.
Activity launch behavior is defined by launch modes in the
AndroidManifest.xml
files of apps, intent flags, and ActivityOptions
provided by the caller. Use ActivityOption#setLaunchDisplayId(int)
to
target a specific display for activity launch.
- By default, the activity launches on the same display as the caller.
For example, a new instance of an activity started from the launcher should be
placed on the same display without additional flags or options. Be sure to use the
correct context (Activity versus Application) for launch.
- If the launch is performed from a source not associated with a specific display
(such as from a shell or Application context), then the activity is placed on the top display
on which the user last interacted with the device or from which the last activity was
launched.
- Intent to launch an activity can be resolved to an existing activity
instance in the system. In such a case, if no additional flags were provided, an
activity surfaces on the same display where it was last used. If the target display
is specified with
ActivityOptions#setTargetDisplayId()
, then the
activity is moved to that display (if allowed by security and other restrictions).
Security restrictions
To prevent a malicious app from misappropriating user-sensitive information
by reading it from the surface of a virtual display that it has created, apps can
launch their own activities only on a virtual display of their creation
in Android 10. However:
- System components with the
INTERNAL_SYSTEM_WINDOW
permission can launch on any display.
- Callers with the
ACTIVITY_EMBEDDING
permission can launch
activities from other apps that have the flag ActivityInfo.FLAG_ALLOW_EMBEDDED
.
- Activity launches on private displays are allowed only for the owner or
activities present on that display.
Similar restrictions apply to adding windows to displays.
Android 10 includes the
ActivityManager#isActivityStartAllowedOnDisplay(Context context, int
displayId, Intent intent)
method to check security restrictions for the
app before attempting to launch on a display. In Android 9
(and lower), restricted launch results throw SecurityException
.
Most security restrictions are applied in the
ActivityStackSupervisor#isCallerAllowedToLaunchOnDisplay()
method.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["# Activity launch policy\n\n*Activity launch behavior* is defined by launch modes in the\n`AndroidManifest.xml` files of apps, intent flags, and ActivityOptions\nprovided by the caller. Use `ActivityOption#setLaunchDisplayId(int)` to\ntarget a specific display for activity launch.\n\n- By default, the activity launches on the same display as the caller. For example, a new instance of an activity started from the launcher should be placed on the same display without additional flags or options. Be sure to use the correct context (Activity versus Application) for launch.\n- If the launch is performed from a source not associated with a specific display (such as from a shell or Application context), then the activity is placed on the top display on which the user last interacted with the device or from which the last activity was launched.\n- Intent to launch an activity can be resolved to an existing activity instance in the system. In such a case, if no additional flags were provided, an activity surfaces on the same display where it was last used. If the target display is specified with `ActivityOptions#setTargetDisplayId()`, then the activity is moved to that display (if allowed by security and other restrictions).\n\nSecurity restrictions\n---------------------\n\nTo prevent a malicious app from misappropriating user-sensitive information\nby reading it from the surface of a virtual display that it has created, apps can\nlaunch their own activities *only* on a virtual display of their creation\nin Android 10. However:\n\n- System components with the `INTERNAL_SYSTEM_WINDOW` permission can launch on any display.\n- Callers with the `ACTIVITY_EMBEDDING` permission can launch activities from other apps that have the flag `ActivityInfo.FLAG_ALLOW_EMBEDDED`.\n- Activity launches on private displays are allowed only for the owner or activities present on that display.\n\nSimilar restrictions apply to adding windows to displays.\n\nAndroid 10 includes the\n`ActivityManager#isActivityStartAllowedOnDisplay(Context context, int\ndisplayId, Intent intent)` method to check security restrictions for the\napp before attempting to launch on a display. In Android 9\n(and lower), restricted launch results throw `SecurityException`.\n\nMost security restrictions are applied in the\n`ActivityStackSupervisor#isCallerAllowedToLaunchOnDisplay()` method."]]