Android Question Access JPG File

MODERN TALKING

Active Member
Licensed User
Longtime User
Hi guys,

Please guide me on how to access a picture I snapped with my phone - which is saved on the phone.

With Code.

I tried: (File.DirRootExternal, "picture1.jpg")

But this doesn't work.

Thank you guys!
 

MODERN TALKING

Active Member
Licensed User
Longtime User
Dim filename As String = "picture1.jpg"
Dim dir As String = File.DirRootExternal

camEx.SavePictureToFile(Data, dir, filename)
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
No. Want another App to access the Image.

Right now the App accesses the DirAssets. I need the SECOND APP to access this JPG snapped with FIRST APP and saved.
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
SECOND APP: myOCR.ExtractFromImage(File.Combine(File.DirAssets, "picture1.jpg"), "", "scene", 20000)

But need it to get "picture1.jpg" which was SNAPPED AND SAVED by FIRST APP on the same Phone.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
another app you wrote? or another app like whatsapp...

if it is an app your wrote and you know the path then just load it from that path.
you saved your image to DirRootExternal so load it from there like this:

B4X:
Dim bmp As Bitmap
bmp.Initialize(File.DirRootExternal,"picture1.jpg")
Activity.SetBackgroundImage(bmp)

if you want other apps to find it on the phone gallery you can use this code (put it after you save your image):

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

MODERN TALKING

Active Member
Licensed User
Longtime User
Thank you Ilan,

But I tried this: myOCR.ExtractFromImage(File.Combine(File.DirRootExternal, "picture1.jpg"),"", "scene", 20000)

and it didn't work.
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
File exists. I can click on it.

Nevermind - I try to figure it out by searching in old posts.

THANK YOU VERY MUCH Ilan
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
when you say you want to access the jpg file what do you mean?
do you want to show it on an imageview? or use it in a different way?

can you post the code when you try to load the image to the control you want to?
explain more what the app is doing with the image
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Optical Character Recognition (OCR)

Get the TEXT from the JPEG.

Sub Activity_Create(FirstTime As Boolean)
myOCR.Initialize(Me, "myOCR", "0451729a-3d4e-4ef5-9bc3-2b3c1ccd60e0")

ProgressDialogShow("WORKING")

'myOCR.ExtractFromImage(File.Combine(File.DirAssets, "picture1.jpg"), "", "scene", 20000)
myOCR.ExtractFromImage(File.Combine(File.DirRootExternal, "picture1.jpg"),"", "scene", 20000)

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