Hi everyone
According to the above tutorial, I want to send a file (any type of file such as mp3, png, etc.)
From b4j to b4a and save on b4a
But after sending the file and saving it in memory, the file can not be used and the Android system can not open the file. Where is the problem ??
Send Code in B4j
Receive code in B4a
[B4X] Network + AsyncStreams + B4XSerializator
Better implementation, based on B4XPages: https://www.b4x.com/android/forum/threads/b4x-b4xpages-network-asyncstreams-b4xserializator.119011/#content New video tutorial: This is a simple and important example. It demonstrates several good practices related to network...
www.b4x.com
According to the above tutorial, I want to send a file (any type of file such as mp3, png, etc.)
From b4j to b4a and save on b4a
But after sending the file and saving it in memory, the file can not be used and the Android system can not open the file. Where is the problem ??
Send Code in B4j
B4X:
'Type MyMessage (Name As String, Age As Int, dbfile() As Byte)
Dim mm As MyMessage
mm.Initialize
mm.Age = edtAge.Text
mm.Name = edtName.Text
mm.dbfile = File.ReadBytes(File.DirApp,"1.mp3")
SendData (ser.ConvertObjectToBytes(mm))
Receive code in B4a
B4X:
Dim mm As MyMessage = ser.ConvertBytesToObject(data)
edtAge.Text = mm.Age
edtName.Text = mm.Name
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow("No permission!",True)
Return
End If
'convert the array of bytes to file
File.WriteBytes(File.DirRootExternal, "1.mp3", data)
Sleep(100)
Log("File saved...")
If File.Exists(File.DirRootExternal, "1.mp3") Then
Log("File Found....")
Else
Log("File Not Found....")
End If