标志FLAG_ACTIVITY_NEW_TASK的解释

标志FLAG_ACTIVITY_NEW_TASK的解释

int android.content.Intent.FLAG_ACTIVITY_NEW_TASK = 268435456 [0x10000000]

 

public static final int FLAG_ACTIVITY_NEW_TASK

Since: API Level 1

If set, this activity will become the start of a new task on this history stack. A task (from the activity that started it to the next task activity) defines an atomic group of activities that the user can move to. Tasks can be moved to the foreground and background; all of the activities inside of a particular task always remain in the same order. See Tasks and Back Stack for more information about tasks.

如果设置了此标志,这个activity将成为一个新task的历史堆栈中的第一个activity。这个task定义了一个原子组activities,用户可以对其进行移除。各种tasks可以移到前面或者后面;在一个特定的task中,所有的activities总是保持相同的顺序。

 

This flag is generally used by activities that want to present a "launcher" style behavior: they give the user a list of separate things that can be done, which otherwise run completely independently of the activity launching them.

 

When using this flag, if a task is already running for the activity you are now starting, then a new activity will not be started; instead, the current task will simply be brought to the front of the screen with the state it was last in. See FLAG_ACTIVITY_MULTIPLE_TASK for a flag to disable this behavior.

当使用这个标志时,如果一个包含此activity的task已经运行了,新的activity不会启动;同时,当前的task将简单的被提到窗口最前面。查看FLAG_ACTIVITY_MULTIPLE_TASK可以禁止这个行为。

 

This flag can not be used when the caller is requesting a result from the activity being launched.

这个标志不能用在调用者需要正在登陆的activity返回一个结果的情况。

 

Constant Value: 268435456 (0x10000000)

 

例如:

// Pressing on the button brings the user back to our mood ring,

// as part of the api demos app.  Note the use of NEW_TASK here,

// since the notification display activity is run as a separate task.

Intent intent = new Intent(this, StatusBarNotifications.class);

intent.setAction(Intent.ACTION_MAIN);

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(intent);

评论 2 您还未登录,请先 登录 后发表或查看评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值