Wrong requestCode in onActivityResult

前端 未结 6 1114
离开以前
离开以前 2020-11-28 01:14

I\'m starting a new Activity from my Fragment with

startActivityForResult(intent, 1);

and want to handle the result in the Fragment\'s pare

6条回答
  •  攒了一身酷
    2020-11-28 01:31

    in Fragment

      getActivity().startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST);
    

    in Main Activity:

    if (requestCode == PLACE_PICKER_REQUEST) {
                if (resultCode == RESULT_OK) {    
         //what ever you want to do
                }
    

提交回复
热议问题