
FLAG_ACTIVITY_CLEAR_TOP launches new instance
错误H1
在使用NavUtils.navigateUpFromSameTask(this)导航到父Activity时,页面切换的动画是从右往左滑动,这样的动画看起来不像是返回动画,而是打开了一个新的页面的动画。
原因H1
SDK版本小于16时,NavUtilsImpl的实现是NavUtilsImplBase,其中的navigateUpTo方法是实现是添加了flagIntent.FLAG_ACTIVITY_CLEAR_TOP。
关于Intent.FLAG_ACTIVITY_CLEAR_TOP,官方文档中是这样描述的
If the activity being started is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it are destroyed and this intent is delivered to the resumed instance of the activity (now on top), through onNewIntent()).
但是实际情况,单单一个Intent.FLAG_ACTIVITY_CLEAR_TOP还是会创建新的实例,在stackoverflow有一个相关的问题。
需要Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP才会执行onNewIntent。
评论
新的评论
上一篇
Junit Rules
Interceptors Junit4.7引入了一个新功能叫做"Interceptors",旨在以一个更为清晰简单的API,带回JUnit meta-testing 的能力。但是之后又被重新命名为"Rule"。 Meta-testing Junit擅长表达尽量少的测试逻辑。在J…
下一篇
关于AsyncTaskLoader
Concurrency基础 Executor Executor 是一个用来执行 Runable 实例的对象,接口定义如下 ExecutorService ExecutorService 继承自 Executor ,也是用来执行 Runable 对象的,但是额外提供了方法能够返回…
