Java Question First b4xlib

yiankos1

Well-Known Member
Licensed User
Longtime User
Hello Team,

I am trying to extend HMS lib with one more method. Scanning QR codes from a bitmap. Here is the github code and the official documentetion. I have been trying over 8 hours to figure out why my code returns null (as QR text result) even everything works fine.

Here is my code:
B4X:
Public Sub scanImage
    Dim options As JavaObject
    options.InitializeNewInstance("com.huawei.hms.ml.scan.HmsScanAnalyzerOptions$Creator", Null)
    Dim HmsScanStatic As JavaObject
    HmsScanStatic.InitializeStatic("com.huawei.hms.ml.scan.HmsScan")
    
    Dim scanUtil As JavaObject
    scanUtil.InitializeStatic("com.huawei.hms.hmsscankit.ScanUtil")

    Dim itypes(Types.Size) As Int
    For i = 0 To Types.Size - 1
        itypes(i) = HmsScanStatic.GetField(Types.Get(i))
    Next

    options.RunMethod("setHmsScanTypes", Array(itypes.Length, itypes))
    options.RunMethod("setPhotoMode",Array(False))
    options = options.RunMethod("create", Null)
    
    Log(Starter.Provider.GetFileUri("frame.png").As(String))
    
    Private obj As JavaObject = scanUtil.RunMethod("decodeWithBitmap",Array(ctxt,scanUtil.RunMethod("compressBitmap",Array(ctxt,Starter.Provider.GetFileUri("frame.png").As(String))),options))
    
    Private tmp As JavaObject
    
    Log(tmp.InitializeNewInstance("com.huawei.hms.ml.scan.HmsScan",obj).RunMethod("getOriginalValue",Null))


End Sub

Thank you for your time.
 

yiankos1

Well-Known Member
Licensed User
Longtime User
Check HMS v1.05.
Thank you one more time Erel for your assistance.
I am more interested in creating wrappers and i am checking your source code. I have two simple questions:

1) Where did you find this method?
B4X:
Return res(0).As(JavaObject).RunMethod("getShowResult", Null)

2) When you want to port a method what do you translate? The documentation, the github code or something else? For example this method.

Thank you for your time again and sorry for these silly questions but i am at the very first steps at b4xlibs.
 
Top