I have a question about StartActivityForResult.

Asked 2 years ago, Updated 2 years ago, 21 views

There are currently four fragments in one fragment activity (main).

From the first fragment, call StartActivityForResult with some activity You have to signal the return value to the main activity and do something during the main activity When I took a log, the ResultCode value went over properly, but the RequestCode kept flying to strange values. I would appreciate it if you could help me with how to solve it.

I took a log again in the fragment now, but the Request Code value is properly imported in the fragment I sent, but the Request Code value keeps changing in the main activity. I think we need to touch the adapter in the main activity in fragment 1 I'd appreciate your help.

android

2022-09-21 15:44

1 Answers

If the fragment is running an activity as follows

startActivityForResult(intent, REQUEST_CODE);

Please change it as below.

getActivity().startActivityForResult(intent, REQUEST_CODE);

See the Stack Overflow link for more information.


2022-09-21 15:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.