为了保持两个Activity原来的状态,而又需要传值,解决这个问题还是很简单:
为了不让Activity 新生成一般要加intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
它表示你跳转的activity如果第一次生成了以后就不在生成了。所以,根据activity的生命周期(这个你们可以自己去跟断点),每次进入activity执行onResume方法,
@Override
protected void onResume() {
Log.i("TEST", "onResume");
Bundle b = getIntent().getExtras();
labelcontent = b.getString("addLabel");
labelNumber = b.getInt("num");
isAgainLoad = b.getBoolean("isAgainLoad");
super.onResume();
};
然后重写onNewIntent方法,这个方法就是在不onDestroy activity的同时,能够传值
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
