Understanding this Java Object thing is driving me nuts !!!
I have the following sub
B4X:
Sub test As JavaObject
Private jo As JavaObject
jo.InitializeStatic("android.hardware.usb.UsbManager")
Private mgr As JavaObject =jo.RunMethod("getAccessoryList",Null)
Return mgr
End Sub
I get : java.lang.IllegalArgumentException: expected receiver of type android.hardware.usb.UsbManager, but got java.lang.Class<android.hardware.usb.UsbManager> on the line Private mgr....
So I must be doing something really stupid, as most of my tests with Java Object are leading to similar results.
You need to understand Java in order to use JavaObject. In this case you are trying to access a non-static method from the class instead of an instance.
However why don't you use USB library instead? It already has a GetAccessories method.
I've been trying to understand the Java Object, as I need it to be able to use an external Jar. So I'm playing with it to learn.
I don't think the USB library will be enough for what I want to do.
I'have been studying Java, but I still haven't understand it's philosophy and learning how to interact between B4A and Jar's seems now of major importance to me.
I did not express myself correctly, Erel. The USB library is OK, as it allows me to get the device I want, but to comunicate with the card reader I need to use the external Jar wich basicly acts as a driver and has all the classes & methods to "talk" with the device...Or at least that is my understanding, which I hope is not wrong.