Dear all,
I have a running B4A Application and would like to extend this Application to send Files and
Text to the PC. Therefore I have made a B4J Application for the PC with the Network examples here
from the community.
In B4A I have this Type:
Type MyMessage (Kennung As String, Text1 As String,Text2 As String,MSG As String, FileTosend() As Byte)
With this Code I send the Stream:
Sub test(msg As String)
Dim mm As MyMessage
mm.Initialize
mm.Kennung="#"
mm.MSG="#"
mm.Text1="#"
mm.Text2="#"
'convert the Image To bytes
Dim out As OutputStream
Dim image1 As Bitmap
image1.Initialize(File.DirAssets,"kwp.jpg")
out.InitializeToBytesArray(0)
image1.WriteToStream(out, 100, "JPEG")
out.Close
mm.FileToSend=out.ToBytesArray
CallSub2(Starter, "SendData", ser.ConvertObjectToBytes(mm))
End Sub
The same declaration in B4J:
Type MyMessage (Kennung As String, Text1 As String,Text2 As String,MSG As String, FileTosend() As Byte)
Receive the Stream in B4J with this code:
Sub AStream_NewData (Buffer() As Byte)
Dim mm As MyMessage
Dim MyBuffer() As Byte
mm=ser.ConvertBytesToObject(Buffer)
Dim in As InputStream
If mm.FileToSend.Length>0 Then
in.InitializeFromBytesArray(mm.FileToSend, 0, mm.FileToSend.Length)
Dim bmp As Image
bmp.Initialize2(in)
Dim Out As OutputStream = File.OpenOutput(File.DirApp, "kwp1.jpg",False)
bmp.WriteToStream(Out)
Out.Close
End If
End Sub
The problem is, that the image is not received at the B4J Application. The FileToSend() is null:
The strange thing is, if I use the Network example with the same code, that the Image is received:
Can someone help me, please?
I'm stocking right now. No idea.
Thank you very much and
Best Regards
Manfred