Android 笔记之 clearTaskOnLaunch&finishOnTaskLaunch

来源:互联网 发布:怎么制作红包软件 编辑:程序博客网 时间:2024/06/06 00:25

看了关于如题中的两条activity的属性,网上的介绍和例子说法不是十分清楚。

遂测试记录之~~~~测试程序包括三个类,one.two.three~

root activity:one

sub activity:two.three 

one有button跳至two...two有button跳至three...

情况1:

在one activity 的配置属性中添加android:clearTaskOnLaunch=“true”,运行应用,点击one的button跳至two.点击two的button跳至three.按home键返回idle,点击launch上此程序图标运行应用。

现象:第一次运行依次执行one.two.three的oncreate,按下home键,三个activity不销毁。二次运行,依次销毁three two activity,返回one activit。

情况2:

在two activity 的配置属性中添加android:finishOnTaskLaunch=“true”,运行应用,点击one的button跳至two.点击two的button跳至three.按home键返回idle,点击launch上此程序图标运行应用。

现象:第一次运行依次执行one.two.three的oncreate,按下home键,三个activity不销毁。二次运行,仅销毁two activity,首先显示three activity,按返回键,返回one activit。

ps:

1,clearTaskOnTaunch紧可以用在root activity . finishOnTaskLaunch紧可以用在非root activity……

2,同时存在以上两条属性时,以clearTaskOnLaunch优先… Chris 20130709