Android Question rescan media

slydog43

Member
Licensed User
Longtime User
I'm having trouble with my program that has 2 activities in it. 1st one browses through a database and displays a pic. If I click on the camera button it goes to another activity and takes a picture. the program is the at the picture is not getting updated on my 1st activity. If I end the program and rerun it it shows the new pic. my pics are being stored in \\mypics on the sd card

here are the 3 methods that I tried, but nothing seemed to work.

any ideas (erel?) Does it have to do with storing them in the sd card?

myDir = File.DirRootExternal & "/myPics/"
myPicFilename = "1.jpg"


'send a broadcast intent to the media scanner to force it to scan the saved file.
Dim Phone As Phone
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", _
"file://" & File.Combine(myDir, myPicFilename))
Phone.SendBroadcastIntent(i)
'------------------------------------------------

' Dim i As Intent
' i.Initialize("android.intent.action.MEDIA_MOUNTED", "file://" & File.Combine(myDir, myPicFilename))
' Dim p As Phone
' p.SendBroadcastIntent(i)
'----------------------------------------------

' Dim context As JavaObject
' context = context.InitializeStatic("anywheresoftware.b4a.BA").GetField("applicationContext")
' Dim paths() As String = Array As String(File.Combine(myDir, myPicFilename)) 'files to scan
' Dim mediaScanner As JavaObject
' mediaScanner.InitializeStatic("android.media.MediaScannerConnection")
' mediaScanner.RunMethod("scanFile", Array As Object(context, paths, Null, Null))
 

slydog43

Member
Licensed User
Longtime User
I'm trying to display a picture that I just took, say with filename 1.jpg, but that file had already existed in the file system, so it was overwritten. My program still displays the old file until I exit program and rerun it. It will then show the new picture not the old one. I thought the media scanner would solve this, but what do I know.
 
Upvote 0
Top