下面列出了怎么用android.app.ActivityOptions的API类实例代码及写法,或者点击链接到github查看源代码。
private void populateGrid() {
grid.setAdapter(new PhotoAdapter(this, relevantPhotos));
grid.addOnItemTouchListener(new OnItemSelectedListener(MainActivity.this) {
public void onItemSelected(RecyclerView.ViewHolder holder, int position) {
if (!(holder instanceof PhotoViewHolder)) {
return;
}
PhotoItemBinding binding = ((PhotoViewHolder) holder).getBinding();
final Intent intent = getDetailActivityStartIntent(MainActivity.this,
relevantPhotos, position, binding);
final ActivityOptions activityOptions = getActivityOptions(binding);
MainActivity.this.startActivityForResult(intent, IntentUtil.REQUEST_CODE,
activityOptions.toBundle());
}
});
empty.setVisibility(View.GONE);
}
boolean startActivity(View v, Intent intent, Object tag) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
// Only launch using the new animation if the shortcut has not opted
// out (this is a
// private contract between launcher and may be ignored in the
// future).
boolean useLaunchAnimation = (v != null)
&& !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
if (useLaunchAnimation) {
ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v,
0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
startActivity(intent, opts.toBundle());
} else {
startActivity(intent);
}
return true;
} catch (SecurityException e) {
Toast.makeText(this, R.string.activity_not_found,
Toast.LENGTH_SHORT).show();
}
return false;
}
/**
* Calling the convertToTranslucent method on platforms after Android 5.0
*/
private static void convertActivityToTranslucentAfterL(Activity activity) {
try {
Method getActivityOptions = Activity.class.getDeclaredMethod("getActivityOptions");
getActivityOptions.setAccessible(true);
Object options = getActivityOptions.invoke(activity);
Class<?>[] classes = Activity.class.getDeclaredClasses();
Class<?> translucentConversionListenerClazz = null;
for (Class clazz : classes) {
if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
translucentConversionListenerClazz = clazz;
}
}
Method convertToTranslucent = Activity.class.getDeclaredMethod("convertToTranslucent",
translucentConversionListenerClazz, ActivityOptions.class);
convertToTranslucent.setAccessible(true);
convertToTranslucent.invoke(activity, null, options);
} catch (Throwable t) {
}
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_settings, container, false);
FloatingActionButton floatingActionButton = (FloatingActionButton) rootView.findViewById(R.id.fab);
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), FabActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getActivity().startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
else
startActivity(intent);
}
});
return rootView;
}
/**
* Calling the convertToTranslucent method on platforms after Android 5.0
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
private static void convertActivityToTranslucentAfterL(Activity activity) {
try {
Method getActivityOptions = Activity.class.getDeclaredMethod("getActivityOptions");
getActivityOptions.setAccessible(true);
Object options = getActivityOptions.invoke(activity);
Class<?>[] classes = Activity.class.getDeclaredClasses();
Class<?> translucentConversionListenerClazz = null;
for (Class clazz : classes) {
if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
translucentConversionListenerClazz = clazz;
}
}
Method convertToTranslucent = Activity.class.getDeclaredMethod("convertToTranslucent",
translucentConversionListenerClazz, ActivityOptions.class);
convertToTranslucent.setAccessible(true);
convertToTranslucent.invoke(activity, null, options);
} catch (Throwable t) {
}
}
/**
* Performs permission check and retrieves the options.
*
* @param intent The intent that is being launched.
* @param aInfo The info of the activity being launched.
* @param callerApp The record of the caller.
*/
ActivityOptions getOptions(@Nullable Intent intent, @Nullable ActivityInfo aInfo,
@Nullable ProcessRecord callerApp,
ActivityStackSupervisor supervisor) throws SecurityException {
if (mOriginalOptions != null) {
checkPermissions(intent, aInfo, callerApp, supervisor, mOriginalOptions,
mOriginalCallingPid, mOriginalCallingUid);
setCallingPidForRemoteAnimationAdapter(mOriginalOptions, mOriginalCallingPid);
}
if (mCallerOptions != null) {
checkPermissions(intent, aInfo, callerApp, supervisor, mCallerOptions,
mRealCallingPid, mRealCallingUid);
setCallingPidForRemoteAnimationAdapter(mCallerOptions, mRealCallingPid);
}
return mergeActivityOptions(mOriginalOptions, mCallerOptions);
}
@Override
public void onMovieClick(@Nullable View movieView, Movie movie) {
if (! mTwoPane) {
Intent intent = new Intent(this, MovieDetailsActivity.class);
intent.putExtra(BundleKeys.MOVIE, Movie.toParcelable(movie));
if (movieView != null) {
ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(movieView, 0, 0,
movieView.getWidth(), movieView.getHeight());
startActivity(intent, opts.toBundle());
} else {
startActivity(intent);
}
} else {
showMovieDetails(movie);
}
}
public static void startWakefullActity(Context context, Intent intent, ActivityOptions activityOptions) {
synchronized (mActiveWakeLocks) {
int id = mNextId;
mNextId++;
if (mNextId <= 0) {
mNextId = 1;
}
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
| PowerManager.SCREEN_BRIGHT_WAKE_LOCK
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "wake:activity");
wl.setReferenceCounted(false);
wl.acquire(60*1000);
mActiveWakeLocks.put(id, wl);
intent.putExtra(EXTRA_WAKE_LOCK_ID, id);
context.startActivity(intent, activityOptions.toBundle());
}
}
@TargetApi(Build.VERSION_CODES.M)
public Bundle getActivityLaunchOptions(View v) {
if (AndroidVersion.isAtLeastMarshmallow) {
int left = 0, top = 0;
int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
if (v instanceof TextView) {
// Launch from center of icon, not entire view
Drawable icon = Workspace.getTextViewIcon((TextView) v);
if (icon != null) {
Rect bounds = icon.getBounds();
left = (width - bounds.width()) / 2;
top = v.getPaddingTop();
width = bounds.width();
height = bounds.height();
}
}
return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height).toBundle();
} else if (AndroidVersion.isAtLeastLollipopMR1) {
// On L devices, we use the device default slide-up transition.
// On L MR1 devices, we use a custom version of the slide-up transition which
// doesn't have the delay present in the device default.
return ActivityOptions.makeCustomAnimation(
this, R.anim.task_open_enter, R.anim.no_anim).toBundle();
}
return null;
}
/**
* Transition animation may cause exception
*/
private void startNeuralNetworkConfig(@NonNull final View view) {
view.setClickable(false);
view.postDelayed(new Runnable() {
@Override
public void run() {
view.setClickable(true);
}
}, 1000);
try {
final Intent intent = new Intent(this, NeuralModelActivity.class);
FabTransform.addExtras(intent,
ContextCompat.getColor(this, R.color.color_accent),
R.drawable.ic_add_white_24dp);
final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
this, view, getString(R.string.transition_neural_config));
startActivity(intent, options.toBundle());
} catch (Exception e) {
ExceptionHelper.getInstance()
.caught(e);
}
}
private void setActivityType(boolean componentSpecified, int launchedFromUid, Intent intent,
ActivityOptions options, ActivityRecord sourceRecord) {
int activityType = ACTIVITY_TYPE_UNDEFINED;
if ((!componentSpecified || canLaunchHomeActivity(launchedFromUid, sourceRecord))
&& isHomeIntent(intent) && !isResolverActivity()) {
// This sure looks like a home activity!
activityType = ACTIVITY_TYPE_HOME;
if (info.resizeMode == RESIZE_MODE_FORCE_RESIZEABLE
|| info.resizeMode == RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION) {
// We only allow home activities to be resizeable if they explicitly requested it.
info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
}
} else if (realActivity.getClassName().contains(LEGACY_RECENTS_PACKAGE_NAME) ||
service.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) {
activityType = ACTIVITY_TYPE_RECENTS;
} else if (options != null && options.getLaunchActivityType() == ACTIVITY_TYPE_ASSISTANT
&& canLaunchAssistActivity(launchedFromPackage)) {
activityType = ACTIVITY_TYPE_ASSISTANT;
}
setActivityType(activityType);
}
@SuppressLint("RestrictedApi")
@Override
public void openPostDetailsActivity(String postId, View v) {
Intent intent = new Intent(FollowingPostsActivity.this, PostDetailsActivity.class);
intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, postId);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
View imageView = v.findViewById(R.id.postImageView);
View authorImageView = v.findViewById(R.id.authorImageView);
ActivityOptions options = ActivityOptions.
makeSceneTransitionAnimation(FollowingPostsActivity.this,
new android.util.Pair<>(imageView, getString(R.string.post_image_transition_name)),
new android.util.Pair<>(authorImageView, getString(R.string.post_author_image_transition_name))
);
startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST, options.toBundle());
} else {
startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST);
}
}
public static void show(Context ctx, String packagename, View source) {
Intent i = new Intent();
ActivityOptions opts = null;
if (source != null) {
opts = ActivityOptions.makeScaleUpAnimation(source, 0, 0, 0, 0);
}
i.setClass(ctx, AppConfigActivity.class);
i.putExtra(EXTRA_PACKAGENAME, packagename);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
if (opts != null) {
ctx.startActivity(i, opts.toBundle());
} else {
ctx.startActivity(i);
}
}
@SuppressLint("RestrictedApi")
@Override
public void openPostDetailsActivity(Post post, View v) {
Intent intent = new Intent(MainActivity.this, PostDetailsActivity.class);
intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, post.getId());
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
View imageView = v.findViewById(R.id.postImageView);
View authorImageView = v.findViewById(R.id.authorImageView);
ActivityOptions options = ActivityOptions.
makeSceneTransitionAnimation(MainActivity.this,
new android.util.Pair<>(imageView, getString(R.string.post_image_transition_name)),
new android.util.Pair<>(authorImageView, getString(R.string.post_author_image_transition_name))
);
startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST, options.toBundle());
} else {
startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST);
}
}
@SuppressLint("RestrictedApi")
@Override
public void openPostDetailsActivity(Post post, View v) {
Intent intent = new Intent(ProfileActivity.this, PostDetailsActivity.class);
intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, post.getId());
intent.putExtra(PostDetailsActivity.AUTHOR_ANIMATION_NEEDED_EXTRA_KEY, true);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
View imageView = v.findViewById(R.id.postImageView);
ActivityOptions options = ActivityOptions.
makeSceneTransitionAnimation(ProfileActivity.this,
new android.util.Pair<>(imageView, getString(R.string.post_image_transition_name))
);
startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST, options.toBundle());
} else {
startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST);
}
}
@SuppressLint("RestrictedApi")
public void openProfileActivity(String userId, View view) {
Intent intent = new Intent(getActivity(), ProfileActivity.class);
intent.putExtra(ProfileActivity.USER_ID_EXTRA_KEY, userId);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view != null) {
View authorImageView = view.findViewById(R.id.authorImageView);
ActivityOptions options = ActivityOptions.
makeSceneTransitionAnimation(getActivity(),
new android.util.Pair<>(authorImageView, getString(R.string.post_author_image_transition_name)));
startActivityForResult(intent, ProfileActivity.CREATE_POST_FROM_PROFILE_REQUEST, options.toBundle());
} else {
startActivityForResult(intent, ProfileActivity.CREATE_POST_FROM_PROFILE_REQUEST);
}
}
@SuppressLint("RestrictedApi")
private void openProfileActivity(String userId, View view) {
Intent intent = new Intent(getActivity(), ProfileActivity.class);
intent.putExtra(ProfileActivity.USER_ID_EXTRA_KEY, userId);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view != null) {
ImageView imageView = view.findViewById(R.id.photoImageView);
ActivityOptions options = ActivityOptions.
makeSceneTransitionAnimation(getActivity(),
new android.util.Pair<>(imageView, getString(R.string.post_author_image_transition_name)));
startActivityForResult(intent, UPDATE_FOLLOWING_STATE_REQ, options.toBundle());
} else {
startActivityForResult(intent, UPDATE_FOLLOWING_STATE_REQ);
}
}
@OnClick(R.id.new_story_post)
protected void postNewStory() {
if (DesignerNewsPrefs.get(this).isLoggedIn()) {
ImeUtils.hideIme(title);
Intent postIntent = new Intent(PostStoryService.ACTION_POST_NEW_STORY, null,
this, PostStoryService.class);
postIntent.putExtra(PostStoryService.EXTRA_STORY_TITLE, title.getText().toString());
postIntent.putExtra(PostStoryService.EXTRA_STORY_URL, url.getText().toString());
postIntent.putExtra(PostStoryService.EXTRA_STORY_COMMENT, comment.getText().toString());
postIntent.putExtra(PostStoryService.EXTRA_BROADCAST_RESULT,
getIntent().getBooleanExtra(PostStoryService.EXTRA_BROADCAST_RESULT, false));
startService(postIntent);
setResult(RESULT_POSTING);
finishAfterTransition();
} else {
Intent login = new Intent(this, DesignerNewsLogin.class);
MorphTransform.addExtras(login, ContextCompat.getColor(this, R.color.designer_news), 0);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
this, post, getString(R.string.transition_designer_news_login));
startActivity(login, options.toBundle());
}
}
public static void startArticleDetailActivity(Context mActivity, ActivityOptions activityOptions, int id, String articleTitle,
String articleLink, boolean isCollect,
boolean isCollectPage,boolean isCommonSite) {
Intent intent = new Intent(mActivity, ArticleDetailActivity.class);
intent.putExtra(Constants.ARTICLE_ID, id);
intent.putExtra(Constants.ARTICLE_TITLE, articleTitle);
intent.putExtra(Constants.ARTICLE_LINK, articleLink);
intent.putExtra(Constants.IS_COLLECT, isCollect);
intent.putExtra(Constants.IS_COLLECT_PAGE, isCollectPage);
intent.putExtra(Constants.IS_COMMON_SITE, isCommonSite);
if (activityOptions != null && !Build.MANUFACTURER.contains("samsung") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mActivity.startActivity(intent, activityOptions.toBundle());
} else {
mActivity.startActivity(intent);
}
}
@SuppressLint("RestrictedApi")
@Override
public void openPostDetailsActivity(Post post, View v) {
Intent intent = new Intent(MainActivity.this, PostDetailsActivity.class);
intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, post.getId());
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
View imageView = v.findViewById(R.id.postImageView);
View authorImageView = v.findViewById(R.id.authorImageView);
ActivityOptions options = ActivityOptions.
makeSceneTransitionAnimation(MainActivity.this,
new android.util.Pair<>(imageView, getString(R.string.post_image_transition_name)),
new android.util.Pair<>(authorImageView, getString(R.string.post_author_image_transition_name))
);
startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST, options.toBundle());
} else {
startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST);
}
}
private void onClickImage(ItemViewHolder holder, Gallery gallery, Image image) {
Intent intent = new Intent(this, GalleryActivity.class)
.putExtra(Intents.EXTRA_GALLERY, Parcels.wrap(gallery))
.putExtra(Intents.EXTRA_IMAGE, Parcels.wrap(image));
Bundle options = null;
if (Const.HAS_L) {
Drawable drawable = holder.photo.getDrawable();
if (drawable != null) {
Holder.set(drawable);
options = ActivityOptions.makeSceneTransitionAnimation(this, holder.photo,
getString(R.string.gallery_photo_hero)).toBundle();
}
}
ActivityCompat.startActivity(this, intent, options);
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
View view = mRecyclerView.findChildViewUnder(e.getX(), e.getY());
if (view != null) {
view.playSoundEffect(SoundEffectConstants.CLICK);
int pos = mRecyclerView.getChildPosition(view);
Intent i = new Intent(getActivity(), ViewEntryActivity.class);
Bundle b = new Bundle();
b.putParcelable(ViewEntryActivity.ENTRY_KEY, mDisplayedEntries.get(pos));
i.putExtras(b);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.buildDrawingCache(true);
Bitmap drawingCache = view.getDrawingCache(true);
Bundle bundle = ActivityOptions.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0).toBundle();
getActivity().startActivity(i, bundle);
} else {
startActivity(i);
}
}
return super.onSingleTapUp(e);
}
public void onStartLaunchBoundsActivity(View view) {
Log.d(mLogTag, "** starting LaunchBoundsActivity");
// Define the bounds in which the Activity will be launched into.
Rect bounds = new Rect(500, 300, 100, 0);
// Set the bounds as an activity option.
ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchBounds(bounds);
// Start the LaunchBoundsActivity with the specified options
Intent intent = new Intent(this, LaunchBoundsActivity.class);
startActivity(intent, options.toBundle());
}
protected void startActivityByAnim(Intent intent, @NonNull View view, @NonNull String transitionName, int animIn, int animExit) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
intent.putExtra(START_SHEAR_ELE, true);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, view, transitionName);
startActivity(intent, options.toBundle());
} else {
startActivityByAnim(intent, animIn, animExit);
}
}
@Override public void onClick(View view) {
if (view == fab) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Intent intent = new Intent(getActivity(), CreateScriptActivity.class);
intent.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR, getRadiant().accentColor());
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
getActivity(), view, getString(R.string.morphing_dialog_transition));
getActivity().startActivityForResult(intent, REQUEST_CREATE_SCRIPT, options.toBundle());
} else {
new CreateScriptDialog().show(getActivity().getFragmentManager(), "CreateScriptDialog");
}
}
}
protected void goToActivity(Intent intent) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
} else {
startActivity(intent);
}
}
/**
* Overrides the activity options with a registered remote animation for a certain calling
* package if such a remote animation is registered.
*/
ActivityOptions overrideOptionsIfNeeded(String callingPackage,
@Nullable ActivityOptions options) {
final Entry entry = mEntries.get(callingPackage);
if (entry == null) {
return options;
}
if (options == null) {
options = ActivityOptions.makeRemoteAnimation(entry.adapter);
} else {
options.setRemoteAnimationAdapter(entry.adapter);
}
mEntries.remove(callingPackage);
return options;
}
/**
* Starts an activity based on the provided {@link ActivityRecord} and environment parameters.
* Note that this method is called internally as well as part of {@link #startActivity}.
*
* @return The start result.
*/
int startResolvedActivity(final ActivityRecord r, ActivityRecord sourceRecord,
IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
int startFlags, boolean doResume, ActivityOptions options, TaskRecord inTask,
ActivityRecord[] outActivity) {
try {
return startActivity(r, sourceRecord, voiceSession, voiceInteractor, startFlags,
doResume, options, inTask, outActivity);
} finally {
onExecutionComplete();
}
}
@Override
public void openProfileActivity(String userId, View view) {
Intent intent = new Intent(PostDetailsActivity.this, ProfileActivity.class);
intent.putExtra(ProfileActivity.USER_ID_EXTRA_KEY, userId);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view != null) {
ActivityOptions options = ActivityOptions.
makeSceneTransitionAnimation(PostDetailsActivity.this,
new android.util.Pair<>(view, getString(R.string.post_author_image_transition_name)));
startActivity(intent, options.toBundle());
} else {
startActivity(intent);
}
}
/**
* Returns the ID of the display to use for a new activity. If the device is in VR mode,
* then return the Vr mode's virtual display ID. If not, if the activity was started with
* a launchDisplayId, use that. Otherwise, if the source activity has a explicit display ID
* set, use that to launch the activity.
*/
private int getPreferedDisplayId(
ActivityRecord sourceRecord, ActivityRecord startingActivity, ActivityOptions options) {
// Check if the Activity is a VR activity. If so, the activity should be launched in
// main display.
if (startingActivity != null && startingActivity.requestedVrComponent != null) {
return DEFAULT_DISPLAY;
}
// Get the virtual display id from ActivityManagerService.
int displayId = mService.mVr2dDisplayId;
if (displayId != INVALID_DISPLAY) {
if (DEBUG_STACK) {
Slog.d(TAG, "getSourceDisplayId :" + displayId);
}
return displayId;
}
// If the caller requested a display, prefer that display.
final int launchDisplayId =
(options != null) ? options.getLaunchDisplayId() : INVALID_DISPLAY;
if (launchDisplayId != INVALID_DISPLAY) {
return launchDisplayId;
}
displayId = sourceRecord != null ? sourceRecord.getDisplayId() : INVALID_DISPLAY;
// If the activity has a displayId set explicitly, launch it on the same displayId.
if (displayId != INVALID_DISPLAY) {
return displayId;
}
return DEFAULT_DISPLAY;
}