I'm new to B4A and am having an issue that is driving me nuts.
I'm trying to take a picture then save it to the gallery. This doesn't seem like it should be this hard.
I'm currently using the code from this thread.
The picture will save in the directory I set, but it never shows up in the gallery.
Here's the code i'm using:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I currently have the targetSdkVersion="26" in the Manifest editor.
			
			I'm trying to take a picture then save it to the gallery. This doesn't seem like it should be this hard.
I'm currently using the code from this thread.
The picture will save in the directory I set, but it never shows up in the gallery.
Here's the code i'm using:
			
				B4X:
			
		
		
		Sub cam_PictureTaken (Data() As Byte)
    filename = DateTime.Now & ".jpg"
    dir = Starter.rp.GetSafeDirDefaultExternal("")
  
    Cam.SavePictureToFile(Data, dir, filename)
    Cam.StartPreview 'restart preview
  
End Sub
Sub continuebtn_Click
    Try  
        If p.SdkVersion<19 Then
      
            Dim i As Intent
            i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "file://" & File.Combine(dir, filename))
            p.SendBroadcastIntent(i)
        Else
           
            Dim context As JavaObject
            context = context.InitializeStatic("anywheresoftware.b4a.BA").GetField("applicationContext")
            Dim paths() As String = Array As String(File.Combine(dir,filename)) 'files to scan
            Dim mediaScanner As JavaObject
            mediaScanner.InitializeStatic("android.media.MediaScannerConnection")
            mediaScanner.RunMethod("scanFile", Array As Object(context, paths, Null, Null))
        End If
        Log("saved")
    Catch
        Log(LastException)
    End Try
End SubI currently have the targetSdkVersion="26" in the Manifest editor.
 
				 
 
		 
 
		 
 
		 
 
		 
 
		