Activity launch mode

  1. Standard: start a activity and add to the top of task stack.
  2. Single Top: If start an activity with this mode, and system find the top of task stack is this kind acvivity, system will reuse the top activity.(onNewIntent() will be called)
  3. Single Task: Clear Top is a better name. If start a activity with this mode, and the task stack has already contains this activity, system will clear all the activities above this activity in this stack, and reuse the activity.(onNewIntent() will be called). If start an activity from another application, the activity will start a new task.
    • If the activity is in background task, start this activity will bring the task to forground. Please refer to Page.202 of Android群英传
  4. Single Instance: There is only one such activity in the system, and the task only host this activity. If the activity does not exist, create a task and create the activity to the task. If the activity already exist, just reuse that activity
    • Suppose A and C are standard, B is single instance, A start B, B start C, C start B; then click BACK button, C is shown, then click BACK button, A is shown.

To set launch mode, there are two ways:
  1. In manifest file: <activity android:launchMode=...>
  2. set intent flags:
    • Intent.FLAG_ACTIVITY_NEW_TASK: will start a new task, but this task can also host other activities that start by this activity. If you start an activity within the same application, this flag is ignored (no task will be created)
    • Intent.FLAG_ACTIVITY_SINGLE_TOP: same as single top mode.
    • Intent.FLAG_ACTIVITY_CLEAR_TOP; same as single task mode.
    • Intent.FLAG_ACTIVITY_NO_HISTORY;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值