Dim scan As JavaObject
'**************************************
' scan.InitializeStatic("android.device.ScanManager")
scan.InitializeNewInstance("android.device.ScanManager",Null)
Dim joOpen As JavaObject
Dim lOpen As Boolean
joOpen = scan.RunMethodJO("openScanner",Null)
lOpen = joOpen.as(Boolean)
the response of compiled is
java.lang.IllegalArgumentException: Expected receiver of type android.device.ScanManager, but got java.lang.Class<android.device.ScanManager>
I can already print through the SDK, doing the following
B4X:
lPrinterReady = False
Dim GetPrinter as JavaObject
GetPrinter.InitializeNewInstance("android.device.PrinterManager",Null)
ob = GetPrinter.RunMethodJO("open",Null)
nPrinterReady = ob.As(Int)
If nPrinterReady=0 Then
cDummy = GetPrinter.RunMethodJO("setupPage",Array As Object(nPW,nPH)).As(String)
cDummy = GetPrinter.RunMethodJO("clearPage",Null).As(String)
....
Printing CODE..
....
end if
According to the instructions of the SDK and the way in which I obtain data is identical to the one I use with the printer, but with the scanner it does not work, it shows me that error.
B4X:
scan.InitializeNewInstance("android.device.ScanManager",Null) <-- Ok no problem
ob = scan.RunMethodJO("openScanner",Null) <-- ERROR
nPrinterReady = ob.As(Int)
or
scan.RunMethodJO("openScanner",Null) <-- ERROR
or
scan.RunMethod("openScanner",Null) <-- ERROR
Usually means that an argument passed to a method is of the wrong type, but I can't see why that would apply here. Can you copy and paste the whole error message from the log?
Usually means that an argument passed to a method is of the wrong type, but I can't see why that would apply here. Can you copy and paste the whole error message from the log?
The second error is expected as openScanner is an instance, not a class,method. However I don't understand the first error as the code looks OK to me. Are you missing a permission?