I want to pick a file from mysdcard (and then I upload to a server). I try to use Intent.ACTION_OPEN_DOCUMENT_TREE to select the file using this post:
How to use the new SD card access API presented for Android 5.0 (Lollipop)?
but when I try to select the file, this is the message I receive from Android studio:
1489-1563/system_process W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client
I've searched on the web, and it seems like no OnclickListener on the item I clicked (?).
This is the code I use to pick the file:
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, 42);
And how I handle the response:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
Uri treeUri = data.getData();
DocumentFile pickedDir = DocumentFile.fromTreeUri(this, treeUri);
// List all existing files inside picked directory
for (DocumentFile file : pickedDir.listFiles()) {
Log.d("PATH FILE", "Found file " + file.getName() + " with size " + file.length());
}
}
}
Where is my error? Sorry but I'm newly in android!