My question is simple. Is it possible to somehow pass extra data with Intent.ACTION_GET_CONTENT
which the Activity
receiving the Intent
in it's onActivityResult()
can read out?
For now I have tried to pass some data over with some standard putExtra()
but that data disappears on it's way to my activity.
Using following code to setup intent.
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/*");
intent.putExtra(CURRENT_REQUEST_CODE_TAG, getTargetRequestCode());
getActivity().startActivityForResult(intent, ADD_SIGNAL_REQUEST_CODE);
And I as I said, the extra data has disappeared when I get the intent in my activity. Is there some way of flagging or setup the intent so it would keep it's extra data or something else that I missing out?
If this isn't possible, are there any other kind of default/standard way of doing this? Note. I would not like to use `Shared Preferences´ for this.
Thanks!
Update
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
int currentRequestCode = data.getIntExtra(CURRENT_REQUEST_CODE_TAG, -1);
}
In my onActivityForResult() the getIntExtra()
always returns the default value of -1, not the one I configured my intent with, which should be value 9 or 10. This tells me that the extra data has been lost, and a debuggin of the data object confirms my suspicions, the intent argument doesn't contain any extra data.
It seems like the intent I send isn't the same that get received in my onActivityResult(). I understand this behaviour because in my case the default Android file chooser is opened and let's the user chose a file of correct MIME type, and when the user selects a file I guess a new Intent is created with the URI to the selected file, but why does the extra data disappear, shouldn't it be kept?