RequestCode parameter in startActivityForResult

When you call startActivityForResult () , you also provide an "int requestCode". How can you get this parameter in the initiated action (to change some kind of initialization there)?

Or do I misunderstand the purpose of this parameter and it is used only to differentiate calls in onActivityResult (), and the initial activity should be initialized based on the Intents action and the additional package? I wonder where it is stored then, I suppose, it is still in the Activity, but private.

+3
source share
2 answers

I think you have few misunderstandings. The RequestCode code is used only in your original action to compare the result. All parameters that you want to pass to the initial action must be passed through additional ones:

Intent.putExtra();
+3
source

I think its the only one to differentiate calls in onActivityResult (). If you want to send special initialization parameters, put them in additional assignment functions.

+1
source

Source: https://habr.com/ru/post/1776672/


All Articles