我有以下工作流程:
- startActivityForResult(Activity1)
- 在 Activity1 上调用 finish() (按下按钮时)
- onActivityResult() ==> startActivityForResult(Activity2)
===> Activity2.onCreate() 在 Activity1.onStop() 之前被调用
为什么我有那个?
编辑:
这是代码:
1- MainActivity.java
// On click on a button
public void start(View view) {
Intent activityIntent = new Intent(this, Activity2.class);
startActivityForResult(activityIntent, 0);
}
protected void onActivityResult(int requestCode,
int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Intent activityIntent = new Intent(this, Activity3.class);
startActivityForResult(activityIntent, 0);
}
2- Activity2.java
// A button to finish the activity
public void stop(View view) {
finish();
}
@Override
protected void onStop() {
super.onStop();
}
3- Activity3.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity3);
}