Reputation: 775
What I am trying to do is the following:
This works fine for Android 4.3:
String path = android.os.Environment.getExternalStorageDirectory().getAbsolutePath()
+ java.io.File.separator + RESPATHCONSTANT
+ java.io.File.separator + filename;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse(path);
intent.setDataAndType(data, "video/mp4");
And then I fire the intent.
For Android 4.3 the Videoplayer takes over now and plays the video.
For Android 4.4 I am able to use a filebrowser, navigate to the video and then use the installed videoplayer to play the video. (the browser has set the appropriate flag, so it is able to browse directories created by other programs) But I am not able to use the method mentioned above. As far as I know from Android 4.4 onwards, applications are only able to read and write to directories on the sdcard, which were created by the application itself. And I'm running into that problem.
How can I store such files and give other programs the permission to read them?
Upvotes: 0
Views: 368
Reputation: 775
Apparently the problem was in another place. The generated URI was fine for Android versions below 4.4, but with Android 4.4 the URI was not prepared appropriately.
With
Uri data = Uri.parse(path);
the URI is of the type StringURI
/storage/emulated/0/.<appname>/r.a4dd6417bd9936aebf3942a0001d33c3.mp4
With
Uri data = Uri.fromFile(new File(path))
the URI is of the type HierarchicalURI
file:///storage/emulated/0/.<appname>/r.a4dd6417bd9936aebf3942a0001d33c3.mp4
Upvotes: 2