Android Question Sending file suing AsyncStreamsObject

warayTek

Member
Licensed User
Hi, I'm trying to test the following code to send a file from B4J to B4A. I could send the file but the result was not as I expected (image below).
samplR.jpg

These are the codes I'm using
B4X:
'Sender B4J
Sub btnSendFile_Action
    Private fs As FileChooser
    fs.Initialize
    Dim ans = fs.ShowOpen(MainForm) As String
    Log(ans)
    Dim lastindex As Int
    Dim vDir,vFilename As String
    'vDir = File.LastModified
    Log(File.GetName(ans))
    vFilename = File.GetName(ans)
    lastindex = ans.LastIndexOf("\")
    Log(lastindex)
    vDir = ans.SubString2(0,lastindex)
    Log(vDir)
    If vDir <> "" Then
        astreamO.WriteFile("file", vDir, vFilename)
        Log("File Sent..")
    Else
   
    End If
End Sub
B4X:
'Receiver B4A

Sub astreamO_NewObject(Key As String, Value As Object)
    Log(Value)
    Select Key
        Case "form"
            Dim p As Person = Value
            txtFirst.Text = p.First
            txtLast.Text = p.Last
            txtAnimal.Text = p.Animal
        Case "simple value"
            Dim number As Int = Value
            ToastMessageShow("Received lucky number: " & number, False)
        Case "image"
            Dim bmp As Bitmap = Value
            Dim r As Rect
            r.Initialize(0, 0, Panel1.Width, Panel1.Height)
            cvs.DrawBitmap(bmp, Null, r)
            Panel1.Invalidate
        Case "file"
            Dim fileName As String = Value
            MsgboxAsync(Value,"Here")
           File.Size(astreamO.TempFolder, fileName)
            Log("Received file. " )
    End Select
End Sub

I think, my trouble is with the sending part of the code. I appreciate any help.

Thanks.
 
Top