Android Question Solved: display file from the Gallery?

anOparator

Active Member
Licensed User
Longtime User
Is there now a way to open a file from the default Gallery, which is on SD card, across many devices?
My SD card has Internal and SD folders but the following code lists an array from the Internal folder.
B4X:
Sub Button1_Click
   List1 = File.ListFiles(File.DirRootExternal)
   Log(List1)
End Sub
Am trying to access the Gallery and show any image without making a List or Map.

Thanks
 
Last edited:

anOparator

Active Member
Licensed User
Longtime User
You should use ContentChooser.
ContentChooser relies on
B4X:
cc.Show("image/*", "Choose image")
which enables choosing one of the images.

My objective is to show each file sequentially:
realPath = /storage/sdcard1/Pictures/1.jpg
realPath = /storage/sdcard1/Pictures/2.jpg
realPath = /storage/sdcard1/Pictures/3.jpg
via a Timer or Button, without first showing folder contents. Once I comprehend the path statement I'm OK.
Is this possible?
thanks
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
ContentChooser lets the user chooses an image from the gallery.

The default folder for pictures is:
B4X:
Dim picturesFolder As String = File.Combine(File.DirRootExternal, "Pictures"))
You can use File.ListFiles to find the files in that folder.

Note that pictures may also be saved in other locations.
 
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
Since contentChooser seems to demand User Interaction my question should have been 'How to make slideshow using the Gallery'. Oops on my part.

All links and pointers appreciated.
 
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
I got it :)
B4X:
Sub btn1_Click
Dim i as Intent
i.Initialize(i.ACTION_VIEW, "file:///storage/sdcard1/Pictures/1.jpg")
i.SetType(" image/*")
StartActivivity(i)
End
Next test is a Map of the folder to step thru.
powered by B4A
 
Upvote 0
Top