Android Question How to save an image to Gallery?

Riddle Ling

Member
Licensed User
How to save an image to Gallery?

My code:
B4X:
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, "Test.jpg", False)
bitmap.WriteToStream(Out, 100, "JPEG")
Out.Close

But did not appear in the Gallery app.
 

DonManfred

Expert
Licensed User
Longtime User
Try this

B4X:
Dim Out AsOutputStream
Out = File.OpenOutput(File.DirRootExternal, "Test.jpg", False)
bitmap.WriteToStream(Out, 100, "JPEG")
Out.Close

Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", _
"file://" & File.Combine(File.DirRootExternal, "Test.jpg"))
Dim p As Phone
p.SendBroadcastIntent(i)
 
Upvote 0

Riddle Ling

Member
Licensed User

Thank you!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…