Why would this Android intent never return?

93 views Asked by At

I'm trying to open the document tree to allow the user to save some data in the location of their choice. Here's code:

public void OpenFilePicker(Uri uriToLoad, int theCode)
{
Intent aIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
aIntent.putExtra("android.content.extra.SHOW_ADVANCED", true);
aIntent.putExtra("android.content.extra.FANCY", true);
mActivity.startActivityForResult(aIntent, theCode);
}

...when this runs, it opens the document tree, allows me to select something, but then I just never get onActivityResult. It just locks up and after a couple seconds says the app is not responding.

What am I doing wrong here?

Edit: Additional info, this happens on devices with Android 11+ on it. 9 (the only lower version I have available) works fine. Is it a security issue?

Final Edit: Idiotic solution... although I "cleaned projec" to force a rebuild all early in the process, evidently "clean project" doesn't actually mean clean the project. By manually deleting the build directories and rebuilding, the problem went away. Something bad was baked into the build that wasn't getting deleted by the rookie move of selecting "clean project" to clean the project. Noted for all future mystery bugs.

0

There are 0 answers