Search code examples
androidactionviewdocumentfile

video file cant play with Action_View uri got from Document file on removeable Storage


I could just get my files on removable storage by action_open_document tree and it gives me a document file. I can not open this file with Action_view. The URI from document file did work! I can open image file with action view .

String uri=DocumentFile.getUri.toString;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri);
intent.setDataAndType(Uri.parse(uri), "video/mp4");
activity.startActivity(intent);

Solution

  • Other apps do not have access to that content. Add FLAG_GRANT_READ_URI_PERMISSION to the Intent to pass along your own read access to the third-party app.