How can I use Intent.ACTION_VIEW to view the contents of a folder?
30,104
Solution 1
I think this is far simpler than everyone else is suggesting. I believe the path is case sensitive. In your example "file://sdcard/Download" should work.
Solution 2
try something like this
Intent intent = new Intent();
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);
or
Intent intent = new Intent();
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on December 19, 2020Comments
-
Admin over 3 years
I'm trying to view the images in a specific folder using an intent. My code is as follows:
Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri imgUri = Uri.parse("file://sdcard/download"); intent.setDataAndType(imgUri, "image/*"); startActivity(intent);
However, each time it runs, I get this message in the log:
02-25 00:40:16.271: ERROR/(8359): can't open '/download'
02-25 00:40:16.271: ERROR/(8359): can't open '/download'What am I doing wrong?