onActivityResult() Intent data is always null

前端 未结 3 512
耶瑟儿~
耶瑟儿~ 2021-02-12 03:16

Can somebody tell my why the Intent data is always null?

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          


        
3条回答
  •  悲&欢浪女
    2021-02-12 03:40

    Make sure that your second activity is not finished before calling

    setResult(RESULT_OK, getIntent().putExtra(ProfileActivity.USER_DATA_EXTRA, constructUser()));
    

    i.e. you should call setResult before onPause, onStop, onDestroy, finish ... etc

提交回复
热议问题