Activity launch behavior is defined by launch modes in the
AndroidManifest.xml files of apps, intent flags, and ActivityOptions
provided by the caller. Use
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).
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_WINDOWpermission can launch on any display
- Callers with the
ACTIVITY_EMBEDDINGpermission can launch activities from other apps that have the flag
- 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
Most security restrictions are applied in the