遍歷

  1. A使用startActivityForResult開啓BA,BA中調用setResult+finish返回A.二者生命週期
A:
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.e("Jet","A:onActivityResult");
    if(resultCode==101){
        Log.e("Jet","A:onActivityResult:101");
    }
}

public void startActivityForResultLC(View view) {
    Intent intent = new Intent(this,BA.class);
    startActivityForResult(intent,100);
}
BA:
public void setResultTest(View view) {
    setResult(101);
    finish();
}

Log:
2018-11-28 11:18:58.837 E/Jet: A:onCreate
2018-11-28 11:18:58.861 E/Jet: A:onStart
2018-11-28 11:18:58.867 E/Jet: A:onResume
2018-11-28 11:19:02.615 E/Jet: A:onPause
2018-11-28 11:19:02.750 E/Jet: BA:onCreate
2018-11-28 11:19:02.760 E/Jet: BA:onStart
2018-11-28 11:19:02.763 E/Jet: BA:onResume
2018-11-28 11:19:03.375 E/Jet: A:onStop
2018-11-28 11:19:09.134 E/Jet: BA:onPause
2018-11-28 11:19:09.162 E/Jet: A:onActivityResult
2018-11-28 11:19:09.162 E/Jet: A:onActivityResult:101
2018-11-28 11:19:09.167 E/Jet: A:onRestart
2018-11-28 11:19:09.168 E/Jet: A:onStart
2018-11-28 11:19:09.172 E/Jet: A:onResume
2018-11-28 11:19:09.733 E/Jet: BA:onStop
2018-11-28 11:19:09.737 E/Jet: BA:onDestroy
複製代碼
相關文章
相關標籤/搜索