diff options
| author | Andrii Kulian <akulian@google.com> | 2016-11-02 12:21:33 -0700 |
|---|---|---|
| committer | Andrii Kulian <akulian@google.com> | 2016-11-15 17:18:32 +0000 |
| commit | 16802aab212b3b070d361f092d78e850b69b18af (patch) | |
| tree | 9b0216a57d200f45bf61bfc139de9d1675fafc4b /core/java/android/app/ActivityOptions.java | |
| parent | 14fee43664bf03d8e50ce864657d0d4d66af7ade (diff) | |
Add API to launch activities on secondary displays
displayId can be specified as a part of ActivityOptions.
We will look for a valid stack on the specified display, starting
from the topmost one. If no valid stack is found, new dynamic stack
can be created on external display.
Launch stack and display id can't be set at the same time, otherwise
exception will be thrown.
Test: ActivityManagerDisplayTests
Test: #testLaunchActivityOnSecondaryDisplay
Test: #testConsequentLaunchActivity
Test: #testConsequentLaunchActivityFromSecondaryDisplay
Test: #testLaunchActivityFromAppToSecondaryDisplay
Change-Id: I8a202bc076319e23948d81b99a2c68d7b733b5e4
Diffstat (limited to 'core/java/android/app/ActivityOptions.java')
| -rw-r--r-- | core/java/android/app/ActivityOptions.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index d9a46903ee38..1e7f4f04582d 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -18,6 +18,7 @@ package android.app; import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; +import static android.view.Display.INVALID_DISPLAY; import android.annotation.Nullable; import android.annotation.TestApi; @@ -152,6 +153,12 @@ public class ActivityOptions { private static final String KEY_ANIM_SPECS = "android:activity.animSpecs"; /** + * The display id the activity should be launched into. + * @hide + */ + private static final String KEY_LAUNCH_DISPLAY_ID = "android.activity.launchDisplayId"; + + /** * The stack id the activity should be launched into. * @hide */ @@ -240,6 +247,7 @@ public class ActivityOptions { private int mResultCode; private int mExitCoordinatorIndex; private PendingIntent mUsageTimeReport; + private int mLaunchDisplayId = INVALID_DISPLAY; private int mLaunchStackId = INVALID_STACK_ID; private int mLaunchTaskId = -1; private int mDockCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; @@ -850,6 +858,7 @@ public class ActivityOptions { mExitCoordinatorIndex = opts.getInt(KEY_EXIT_COORDINATOR_INDEX); break; } + mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY); mLaunchStackId = opts.getInt(KEY_LAUNCH_STACK_ID, INVALID_STACK_ID); mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1); mTaskOverlay = opts.getBoolean(KEY_TASK_OVERLAY, false); @@ -1015,6 +1024,25 @@ public class ActivityOptions { } } + /** + * Gets the id of the display where activity should be launched. + * @return The id of the display where activity should be launched, + * {@link android.view.Display#INVALID_DISPLAY} if not set. + */ + public int getLaunchDisplayId() { + return mLaunchDisplayId; + } + + /** + * Sets the id of the display where activity should be launched. + * @param launchDisplayId The id of the display where the activity should be launched. + * @return {@code this} {@link ActivityOptions} instance. + */ + public ActivityOptions setLaunchDisplayId(int launchDisplayId) { + mLaunchDisplayId = launchDisplayId; + return this; + } + /** @hide */ public int getLaunchStackId() { return mLaunchStackId; @@ -1209,6 +1237,7 @@ public class ActivityOptions { b.putInt(KEY_EXIT_COORDINATOR_INDEX, mExitCoordinatorIndex); break; } + b.putInt(KEY_LAUNCH_DISPLAY_ID, mLaunchDisplayId); b.putInt(KEY_LAUNCH_STACK_ID, mLaunchStackId); b.putInt(KEY_LAUNCH_TASK_ID, mLaunchTaskId); b.putBoolean(KEY_TASK_OVERLAY, mTaskOverlay); |
