I have embedded the camera example in a much larger app that is working well, but would like to better understand the android intent that forms part of the camera example.
the code (thank you Erel) segment shown below captures and stores the images within my app.
Sub Camera1_PictureTaken (Data() As Byte)
Dim dir As String = Main.photoDir
Dim filename As String = Main.photoID & ".jpg"
camera1.StartPreview
Dim out As OutputStream
out = File.Openoutput(dir,filename,False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
Dim Phone As Phone
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", _
"file://" & File.Combine(dir, filename))
Phone.SendBroadcastIntent(i)
ToastMessageShow("Image saved: " & Main.photodir & Main.photofilename, True)
btnTakePicture.Enabled = True
End Sub
The sub above captures and stores the image(s) exactly as anticipated, however, the images are stored in exactly the same way with or without the 4 lines of code;
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", _
"file://" & File.Combine(dir, filename))
Phone.SendBroadcastIntent(i)
My question is; what exactly does the intent action MEDIA_SCANNER_SCAN_FILE do? In reading many of the forum questions and answers I thought (apparently incorrectly) that this would result in the folder where the images are stored being recognized as a folder by the Gallery application. This does not appear to be the case.
I've spent several hours in the b4a forums and other web sites but have only managed to become more confused. I would really appreciate an explanation (hopefully without disappearing down a technical rabbit hole) as to what exactly the media scan does and why it should be used in the camera example.
Thanks in advance.
P.S. as a newcomer to B4A and the forums I really appreciate the wealth of information and knowledge that is so willingly shared by the B4A community.
the code (thank you Erel) segment shown below captures and stores the images within my app.
Sub Camera1_PictureTaken (Data() As Byte)
Dim dir As String = Main.photoDir
Dim filename As String = Main.photoID & ".jpg"
camera1.StartPreview
Dim out As OutputStream
out = File.Openoutput(dir,filename,False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
Dim Phone As Phone
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", _
"file://" & File.Combine(dir, filename))
Phone.SendBroadcastIntent(i)
ToastMessageShow("Image saved: " & Main.photodir & Main.photofilename, True)
btnTakePicture.Enabled = True
End Sub
The sub above captures and stores the image(s) exactly as anticipated, however, the images are stored in exactly the same way with or without the 4 lines of code;
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", _
"file://" & File.Combine(dir, filename))
Phone.SendBroadcastIntent(i)
My question is; what exactly does the intent action MEDIA_SCANNER_SCAN_FILE do? In reading many of the forum questions and answers I thought (apparently incorrectly) that this would result in the folder where the images are stored being recognized as a folder by the Gallery application. This does not appear to be the case.
I've spent several hours in the b4a forums and other web sites but have only managed to become more confused. I would really appreciate an explanation (hopefully without disappearing down a technical rabbit hole) as to what exactly the media scan does and why it should be used in the camera example.
Thanks in advance.
P.S. as a newcomer to B4A and the forums I really appreciate the wealth of information and knowledge that is so willingly shared by the B4A community.