I have to ask the user for the name of the folder where a file is to be saved.
I also have to send information related to the name of the file that is supposed to be saved.
Is there any way to send this information along with the intent?
If I do this:
Intent originalIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
originalIntent.putExtra("extra",blabla);
originalIntent.putExtra(EXTRA_TITLE, getString(R.string.choose_dir));
startActivityForResult(originalIntent, REQUEST_CHOOSE_DIR);
in onActivityResult I cannot see any extra information
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(data.getExtras() != null)
{
//do stuff here
}
}
data.getExtras is always null
If you mean "send this information along, such that I will get it back in
onActivityResult()
", then no. You need to hold onto that data in whatever is making the request (activity, fragment, etc.), or in something associated with it (e.g., viewmodel).