asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
当主Activity设置了lauchMode为singleTask的时候, 每次长按home返回的时候都会返回到主Activity。这并不是我们想要的结果。

This is not a bug. When an existed "singleTask" activity is launching, all other activities above it in the stack will be destroyed.

When you press HOME and launch the activity again, ActivityManger calls an intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flat=FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_RESET_IF_NEEDED cmp=A}, so the result is A > B > HOME > A.

It's different when A's launchMode is "Standard". The task which contains A will come to the foreground and keep the state the same as before.

You can create a "Standard" activity eg. C as the launcher and startActivity(A) in the onCreate method of C

OR

Just remove the launchMode="singleTask" and set FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP flag whenever call an intent to A

posted on 2011-08-29 18:18 汪杰 阅读(270) 评论(0)  编辑 收藏 引用 所属分类: Java
只有注册用户登录后才能发表评论。

<2006年4月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 466814
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜