发现linux下源码编译出来的SDK文档和windows上下载的SDK中的文档内容安排有很大不同,于是两者参照着看。发现下面两个互相矛盾的地方,求解答。
在linux下的SDK文档中singleTask的activity如果在task中它的上面有其他activity的话,它就不处在处理intent的位置,会丢弃intent。
A "singleInstance" activity is always at the top of the stack (since it is the only activity in the task), so it is always in position to handle the intent. However, a "singleTask" activity may or may not have other activities above it in the stack. If it does, it is not in position to handle the intent, and the intent is dropped. (Even though the intent is dropped, its arrival would have caused the task to come to the foreground, where it would remain.)而在windows的sdk中有这样的描述。这里没有区分是否有其他activity在该activity之上,按理说应该就是全部是这样处理的。
The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time.岂不是有些矛盾?

解决方案 »

  1.   

    这里的问题还真多啊
    看了下面这篇文章
    http://www.linuxidc.com/Linux/2011-08/41837.htm文中的例子岂不是和The system creates a new task and instantiates the activity at the root of the new task.相矛盾?新启动的singletask activity也不一定就是task的根元素啊。
    而且作者最后总结说:如果设置了"singleTask"启动模式的Activity不是在新的任务中启动时,它会在已有的任务中查看是否已经存在相应的Activity实例,如果存在,就会把位于这个Activity实例上面的Activity全部结束掉,即最终这个Activity实例会位于任务的堆栈顶端中。和上面SDK文档又有所差异,何解????
      

  2.   

    如果没有 the system routes the intent to the existing instance through a call to its onNewIntent() method 这句,3段话说的是一个意思。假设一个task的root activity是singleTask的(设为 A),这时再又另外一个Acitivity 发一个intent要求启动 A。 那么A上面的所有activity会被清空。这时如果你不在A中调用onNewIntent() 去重新获取一次intent ,那么新传来的intent不会起作用,仅仅是把A带到前台来。但如果你调用onNewIntent() 重新设置一次 intent ,那么新的intent的数据会替换原来A中老的intent
      

  3.   


    onNewIntent() 不是系统自己调用的么?应该在什么地方调用呢