Intent setFlag Activity 相关 1

 
 FLAG_ACTIVITY_NO_HISTORY 
 

 If set, the new activity is not kept in the history stack.  As soon as the user navigates away from it, the activity is finished. 

e.g.  MainActivity --> FirstActivity -> SecondActivity

MainActivity 在使用Intent启动FirstActivity 时setFlag,即

		Intent intent = new Intent(this, FirstActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
		startActivity(intent);
FirstActivity( As soon as the user navigates away from it, the activity is finished. 

也就是说如果按返回键,返回的 顺序是 SecondActivity ->MainActivity


PS: 从下图可以看出FirstActivity 触发OnDestroy的时机并不是确定的,但是在返回的时候,都是会做destroy


Intent setFlag Activity 相关 1_第1张图片Intent setFlag Activity 相关 1_第2张图片


FLAG_ACTIVITY_SINGLE_TOP

If set, the activity will not be launched if it is already running
     * at the top of the history stack.


你可能感兴趣的:(Intent setFlag Activity 相关 1)