SingleTask的Activity启动模式遇到的一个奇怪现象

只能怪自己,现在还真是菜鸟了,以后一定记得要回来研究一下:

今天因为改别人的框架,想自己处理一下希望可以用,发现一个以前没注意到的现象(在onResume中重写代码):

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();

		Log.e("onResume", "onResume");
		Intent intent = new Intent(MainActivity.this, SecondActivity.class);
		startActivityForResult(intent, 100);
		finish();
	}
没想到第二个activity竟然不会马上启动,而是这样的顺序:


而startActivity顺序和以前的一样。

@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();

		Log.e("onResume", "onResume");
		Intent intent = new Intent(MainActivity.this, SecondActivity.class);
		startActivity(intent);
		finish();
	}
结果和以前一样:

之所以记录这个是因为想通过在onResume()中判断一个值,然后确定是否跳转到别的Activity,

每次在onpause的时候都会把这个值再次更改为false,

不管它本来的值是不是false,因为onpause已经执行了,再次执行onResume了,所以,结果就一直错了。。

你可能感兴趣的:(android,疑惑待解,SingleTask)