I am developing an android app that targets android tv and part of the app requirement is that users need to save files on the SD card. To access the file system, I am trying to use Storage Access Framework (SAF). To test using SAF, I created a sample activity. Here is the code which I use to launch the file browser activity:
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(i, REQUEST_CODE);
Then on the onActivityResult
method I display a simple toast just for testing purposes. Here is the method
@Override
public void onActivityResult(int requestCode, int resultCode,
Intent resultData) {
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
Uri uri = null;
if (resultData != null) {
uri = resultData.getData();
}
Toast.makeText(this, "Path: " + uri.getPath(), Toast.LENGTH_LONG).show();
}
When testing the sample activity that has the above code on my mobile phone (Android 5.0) it works successfully. However, testing it on android tv box and also android tv emulator (both Android 6.0), I get the following exception:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT typ=/ }
Isn't Storage Access Framework not supported on android tv? What can I do to resolve this issue