Android Question [Resolved] Opening image files whose names are in Cyrillic

Sergey_New

Well-Known Member
Licensed User
Longtime User
Tried with ImageView and WebView - error (file not found). The files are located in the program folder.
Tell me, please, a solution.
The programs built into the emulator and the device open these files.
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
The simplest code:
B4X:
Dim photo As ImageView
photo.Bitmap = LoadBitmap(folder, filename)
Or
B4X:
Dim wV As WebView
wV.LoadHtml ("<html><body style='margin: 0px; padding: 0px'><img src='" & folder & filename & "' width='200' /></body></html>")
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Нет проблем)
 

Attachments

  • photo.zip
    13.9 KB · Views: 159
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
What is the value of "folder" variable? If it is File.DirAssets it will not work.
This works:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    File.Copy(File.DirAssets, "Кеннеди.jpg", File.DirInternal, "Кеннеди.jpg")
End Sub

Sub Button1_Click
    Dim folder As String = File.DirInternal
    Dim FileName As String ="Кеннеди.jpg"

    Dim Html As String = $"<html><body style='margin: 0px; padding: 0px'><img src='${folder}/${FileName}' width='200' /></body></html>"$
    WebView1.LoadHtml (Html)
End Sub
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
My application creates a folder of programs:
B4X:
File.MakeDir (File.DirRootExternal, Starter.ProgName)
File.MakeDir (File.DirRootExternal & "/" & Starter.ProgName, "Медиа")
The image files are located in the "Медиа" folder.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
I'm sure. Files in Latin are read normally.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Well, I tested as above and I tested also with:
B4X:
wV.LoadHtml ("<html><body style='margin: 0px; padding: 0px'><img src='" & Folder & FileName & "' width='200' /></body></html>")
I don't get any error "File not found" ?!
The only problem is that nothing is displayed in the WebView.
I also copied the file from File.DirAssets to File.DirInternal, no error and nothing is displayed.

You should post the full error message.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
 

Attachments

  • CyrillicTest.zip
    14.2 KB · Views: 129
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
klaus, when using ImageView:
java.io.FileNotFoundException: /storage/emulated/0/Поколения/Медиа/кеннеди.jpg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:214)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:516)
at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1342)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at sv.bystrovzorov.datamedia._openimg(datamedia.java:886)
at sv.bystrovzorov.datamedia._setmedia(datamedia.java:974)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
And when using WebView, the image is not shown.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…