JTmartins Active Member Licensed User Longtime User Oct 22, 2014 #1 Hi, I'v faced this situation, where I have to pass some parameters to an external jar but some are arrays and others are not. The java code is : Code: Copy public int transmit(int slotNum, byte[] sendBuffer, int sendBufferLength, byte[] recvBuffer, int recvBufferLength) Now in my B4A I have Code: Copy Private SendBuffer(6) As Byte SendBuffer(0)=0x00 SendBuffer(1)=0xA4 SendBuffer(2)=0x08 SendBuffer(3)=0x0C SendBuffer(4)=0x02 SendBuffer(5)=0x2F Private recvBuffer(300) As Byte and the JavaObject Line would be something similar as the one below, wich obviously does not work. Code: Copy Dim response As JavaObject response=mReader.RunMethod("transmit", Array As JavaObject (slotnum, Array As Byte (SendBuffer()) ,SendBuffer.Length, Array As Byte (recvBuffer()), recvBuffer.Length )) I've looked java.initialize array, but I could not figure how to use it in this situation. every different attempts I've tryed always lead me to java.lang.IllegalArgumentException: Array has incompatible type: I'me prety sure there is a solution, as always, Help ! Last edited: Oct 22, 2014
Hi, I'v faced this situation, where I have to pass some parameters to an external jar but some are arrays and others are not. The java code is : Code: Copy public int transmit(int slotNum, byte[] sendBuffer, int sendBufferLength, byte[] recvBuffer, int recvBufferLength) Now in my B4A I have Code: Copy Private SendBuffer(6) As Byte SendBuffer(0)=0x00 SendBuffer(1)=0xA4 SendBuffer(2)=0x08 SendBuffer(3)=0x0C SendBuffer(4)=0x02 SendBuffer(5)=0x2F Private recvBuffer(300) As Byte and the JavaObject Line would be something similar as the one below, wich obviously does not work. Code: Copy Dim response As JavaObject response=mReader.RunMethod("transmit", Array As JavaObject (slotnum, Array As Byte (SendBuffer()) ,SendBuffer.Length, Array As Byte (recvBuffer()), recvBuffer.Length )) I've looked java.initialize array, but I could not figure how to use it in this situation. every different attempts I've tryed always lead me to java.lang.IllegalArgumentException: Array has incompatible type: I'me prety sure there is a solution, as always, Help !
Daestrum Expert Licensed User Longtime User Oct 22, 2014 #2 Have you tried (as the compiler should know which items are arrays) Code: Copy response=mReader.RunMethod("transmit", Array(slotnum, SendBuffer ,SendBuffer.Length, recvBuffer, recvBuffer.Length )) Upvote 0
Have you tried (as the compiler should know which items are arrays) Code: Copy response=mReader.RunMethod("transmit", Array(slotnum, SendBuffer ,SendBuffer.Length, recvBuffer, recvBuffer.Length ))
JTmartins Active Member Licensed User Longtime User Oct 23, 2014 #3 That was my first attempt wich gave me java.lang.reflect.InvocationTargetException Caused by: java.lang.IllegalArgumentException I have to look deeper into this, as this may indicate an error in the parameters I'm sending, but in the mean time if some one can throw some ideas, I would appreciate. Many thanks Daestrum Upvote 0
That was my first attempt wich gave me java.lang.reflect.InvocationTargetException Caused by: java.lang.IllegalArgumentException I have to look deeper into this, as this may indicate an error in the parameters I'm sending, but in the mean time if some one can throw some ideas, I would appreciate. Many thanks Daestrum
JTmartins Active Member Licensed User Longtime User Oct 23, 2014 #4 Yeap. You where right Daestrum...It was my mistake. Sending incorrectly formed arrays. I still haven't decyphered the responses, but I'm getting them now. Upvote 0
Yeap. You where right Daestrum...It was my mistake. Sending incorrectly formed arrays. I still haven't decyphered the responses, but I'm getting them now.