onNewIntent()与singleTask启动模式

当有一个活动A设置启动模式为singleTask模式时。

 又有多个其他活动需 经过Intent 跳转到活动A,并附带信息。 那么肯定会设置action!

当活动A 判定是哪一个活动过来的时候。

  当活动A没被系统杀了。活动A的oncreate 将不执行,先执行onNewIntent,再onResume!

 所以在onNewIntent里面 可

  1. @Override   
  2. public   void  onNewIntent(Intent arg0) {  
  3.     // TODO Auto-generated method stub   
  4.     super .onNewIntent(arg0);  
  5.     System.out.println("OnNewIntent进来了" );  
  6.     setIntent(arg0);  
  7.     intent = this .getIntent();  
  8. }  
	@Override
	public void onNewIntent(Intent arg0) {
		// TODO Auto-generated method stub
		super.onNewIntent(arg0);
		System.out.println("OnNewIntent进来了");
		setIntent(arg0);
		intent = this.getIntent();
	}

 关键是 setintent(arg0);

 只有设置了这个 才会更新 intent。(action)
否则一直是第一个跳转到活动A的那个intent的action

猜你喜欢

转载自yulincqupt.iteye.com/blog/1680367