android-如何在新任务中打开一个新活动,并让它发生在当前任务的后面?

android-如何在新任务中打开一个新活动,并让它发生在当前任务的后面?,android,Android,在android 6.0上使用chrome时,我可以长按一个链接,选择“在新选项卡中打开”,然后将其打开到当前任务后面的另一个任务中 现在我需要做一些熟悉的事情,但是我不知道如何让我的活动在一个新任务中开始,并让任务在当前任务后面以奇特的动画开始 我发现 public static final int ANIM\u LAUNCH\u TASK\u BEHIND=7 在ActivityOptions.java中,有一个javadoc: /** * If set along with Intent

在android 6.0上使用chrome时,我可以长按一个链接,选择“在新选项卡中打开”,然后将其打开到当前任务后面的另一个任务中

现在我需要做一些熟悉的事情,但是我不知道如何让我的活动在一个新任务中开始,并让任务在当前任务后面以奇特的动画开始

我发现

public static final int ANIM\u LAUNCH\u TASK\u BEHIND=7

在ActivityOptions.java中,有一个javadoc:

/**
 * If set along with Intent.FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be
 * presented to the user but will instead be only available through the recents task list.
 * In addition, the new task wil be affiliated with the launching activity's task.
 * Affiliated tasks are grouped together in the recents task list.
 *
 * <p>This behavior is not supported for activities with {@link
 * android.R.styleable#AndroidManifestActivity_launchMode launchMode} values of
 * <code>singleInstance</code> or <code>singleTask</code>.
 */
public static ActivityOptions makeTaskLaunchBehind() {
    final ActivityOptions opts = new ActivityOptions();
    opts.mAnimationType = ANIM_LAUNCH_TASK_BEHIND;
    return opts;
}

所以android似乎支持这个功能,但我不知道如何使用它。有人做过类似的事情吗?如何在新任务内部打开新活动,并让其在当前任务之后发生

好吧,在源代码中进行一些搜索之后,我发现动画类型可以通过startActivity中传递的选项来指定……但是请求此功能的键和值似乎不是公共的,因为我无法直接访问它们。但是,毕竟,我可以通过以下代码请求此功能:

Intent intent = new Intent(MainActivity.this, TestActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Bundle bundle = new Bundle();
bundle.putInt("android:activity.animType", 7);
startActivity(intent, bundle);
现在我想知道有没有更好、更标准的方法来请求此功能?使用文本字符串而不是某个类的常量字段看起来很危险