0

I have a weird problem, I am playing a video file from local storage, if the video name is "test#.mp4" it does not work and shows "media not found" toast, if it's "test.mp4", it works fine, no idea where is the problem. basically if the name has "#" anywhere, the video does not play. Here is my code

String item = names.get(itemPosition); // file name eg. test#.mp4
Uri uri  = Uri.parse(context.getExternalFilesDir(null).getAbsolutePath() + "/MyFiles/"+item); // path to file
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
intent.setDataAndType(uri, "video/*");
context.startActivity(intent);
Mohad12211
  • 353
  • 3
  • 9

1 Answers1

0

The answer is that I needed to use FileProvider, I have no idea why my earlier method was working and sometimes not.Also because the original documentation is so confusing, I used this answer, I took a look at the actual Uri and everything made sense now! android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData()

Mohad12211
  • 353
  • 3
  • 9