Camera, TakePicture, Android Gallery

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I seem to have the opposite question that has been asked previously in these forms. I have an App that uses the Camera library, TakePicture. Pretty much using the code directly from Erel's tutorial, I save the picture in the DirRootExternal/Pictures directory in a folder I create, MyPics/.

Using EsFileManager I can see that the directory and jpg picture file exist and I can open the JPEG file in EsFileManager.

If I open the Android Gallery app, the Album (directory) and JPEG file are not visible.

If instead I create the directory, MyPics2, and copy a JPEG image into that directory using EsFileManager then open the Android Gallery App, the Album MyPics2 and JPEG are visible.

In short, if I create a directory in Pictures and save a file via B4A, it does not show up when I open Android's Gallery App. If I create the directory and copy the JPEG file via EsFileManager it does show up in Android's Gallery.

Searching the Internet I find many have this problem of Gallery not refreshing its list of Albums, but no fix suggestions.

Does anyone know how to make the images saved via B4A show up in the Android Gallery?

Thanks,
Barry.
 

canalrun

Well-Known Member
Licensed User
Longtime User
Try searching for media scanner and see if that works.

Thanks. The searches turned up:

B4X:
public static void GalleryRefresh()
{
    me.sendBroadcast(new Intent(Intent.ACTION\_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
}

I will give this a shot once I translate to B4A.

Added later:
Turns out there is an example in the help for "Phone"

B4X:
Example of asking the media scanner to rescan a file:
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "file://" & File.Combine(File.DirRootExternal, "pictures/1.jpg"))
Dim p As Phone
p.SendBroadcastIntent(i)

Barry.
 
Last edited:
Upvote 0
Top