JTmartins Active Member Licensed User Longtime User Oct 18, 2014 #1 Understanding this Java Object thing is driving me nuts !!! I have the following sub Code: Copy 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. What am I referencing wrong ? Thanks
Understanding this Java Object thing is driving me nuts !!! I have the following sub Code: Copy 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. What am I referencing wrong ? Thanks
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2014 #2 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. Upvote 0
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.
JTmartins Active Member Licensed User Longtime User Oct 19, 2014 #3 Thanks Erel, 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. Upvote 0
Thanks Erel, 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.
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2014 #4 JTmartins said: I don't think the USB library will be enough for what I want to do. Click to expand... What are you missing? Upvote 0
JTmartins said: I don't think the USB library will be enough for what I want to do. Click to expand... What are you missing?
JTmartins Active Member Licensed User Longtime User Oct 19, 2014 #5 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. Upvote 0
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.