Hello
I raise an event from Java with a byte array as argument:
In B4A I want to update the data argument which should be returned to Java. Because I do not know the size of the array before raising the event, the array is not initialized. How can I update the array in B4A without loosing the reference?
I tried this:
ArrayCopy works only if the array had already the correct size before raising the event and I do not have to redim it. But as I do not know the size before, I can't do that. So how can I pass back a byte array with unknown size in an event argument?
Thank you!
I raise an event from Java with a byte array as argument:
B4X:
private int Read(long userdata, byte[] data, int size, Object actual) {
ba.raiseEvent(this, eventName + "_read", userdata, data, size, actual);
ba.Log("First Byte: " + data[0]);
return 0;
}
In B4A I want to update the data argument which should be returned to Java. Because I do not know the size of the array before raising the event, the array is not initialized. How can I update the array in B4A without loosing the reference?
I tried this:
B4X:
Private Sub LibDC_Read(Userdata As Long, Data() As Byte, Size As Int, Actual As Object) As Int
Dim TempArr() As Byte
'Does not work:
TempArr = File.ReadBytes(Common.LogDir, "File.bin")
Data = Temparr
'Does not work:
Dim bc As ByteConverter
Dim Data(TempArr.Length) As Byte
bc.ArrayCopy(TempArr, 0, Data, 0, TempArr.Length)
Return 0
End Sub
ArrayCopy works only if the array had already the correct size before raising the event and I do not have to redim it. But as I do not know the size before, I can't do that. So how can I pass back a byte array with unknown size in an event argument?
Thank you!