只能怪自己,现在还真是菜鸟了,以后一定记得要回来研究一下:
今天因为改别人的框架,想自己处理一下希望可以用,发现一个以前没注意到的现象(在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开发中onResume()方法中处理活动跳转时的顺序问题,通过实例展示了如何在onResume()中判断并确定是否跳转到另一个活动,以及onPause和onResume方法之间的交互如何影响跳转行为。
1352

被折叠的 条评论
为什么被折叠?



