Android Tutorial FileTransfer - Send and receive files with AsyncStreams

Status
Not open for further replies.

Mbc

Member
Licensed User
Longtime User

anywheresoftware.b4a.samples.bluetooth:
The log when running in Debug does not produce any error.
De app however gives an error text when running in Debug: "Connection broken".
The last four lines in the log:
connected: true
** Activity (main) Pause, UserClosed = false **
** Activity (chatactivity) Create, isFirst = true **
** Activity (chatactivity) Resume **
 

Mbc

Member
Licensed User
Longtime User
The FileTransfer example will only work with two Android devices that run this app.

That makes perfect sense, but how about anywheresoftware.b4a.samples.bluetooth?
The aim of the exercise is to program Android using Basic4Android as to communciactie via BT with the Arduino paltform.
 

GMan

Well-Known Member
Licensed User
Longtime User
The aim of the exercise is to program Android using Basic4Android as to communciactie via BT with the Arduino paltform.
Communication via BT is quite easy, works perfect with several HC-xx devices and several Arduino board types
 

Mbc

Member
Licensed User
Longtime User

GMan

Well-Known Member
Licensed User
Longtime User
but with Serial example
Yes, thats the SPP protocol Erel and I told about.

Finally: Congrats to get it work
 

B4A Enthusiast

Member
Licensed User
Longtime User
Hi, am implementing the Asynchronous file transfer code provided in C# in prefix mode. My desktop module is able to send the requested file as shown in the image below:



My problem however is that when the transferred file(s) are saved in the device they are assigned file names that are numeric and without the original file name extensions. How can i ensure that the files saved in the device have the same original filenames as found in the desktop pc? The code for saving is attached here below:

B4X:
Sub AStream_NewStream (Dir As String, FileName As String)
    'this event is raised when a file was received successfully
    Timer1_Tick
    timer1.Enabled = False
'    lblFile = currentFile & " completed"
    ReceivingFile = False
    UpdateProgress
    File.Copy(Dir, FileName, Dir, currentFile)
    File.Delete(Dir, FileName)
End Sub
 
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
Can't you name the target FileName ?
 

Douglas Farias

Expert
Licensed User
Longtime User
hi @Erel
i have try the example and i have this error


i dont make changes, only compiled this.
my device is MOTO G
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you indeed, Erel, for a very useful app.

The code for me is beyond my technical expertise since I never had much exposure to network foundations. And as you stated in post 17,
... the code is quite complicated.
However, it is impressive, to say the least. My experience and some questions follow.

Test Environment: 3 Tablets A, B, C running 4.0, 4.3, and 4.4. in the same network
My Testing Results using WiFi ONLY:
1. Connected A to B, B to C. A to C.
2. Transferred files ranging from 1KB to 7MB back and forth.

Findings/Questions
Case 1: A and B Connected. Transfer 7MB File from A to B. Connected C to A - file transfer froze either direction. Shouldn't the File Transfer take priority and deny the new connection?
Case 2: Cannot connect A and B to C at the same time. Can this be done? (Remember my tech limitations.)
Case 3: Is there a way to know which tablet is connected to which tablet. I know Socket.ResolveHost is deprecated.

Any and all help is always welcomed.

Best regards.

Sandy
 
Last edited:

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Erel.

1. Is there a way to know which IP address is connected to the tablet on wifi?
2. A and B Connected. Transfer 7MB File from A to B. Connected C to A - file transfer froze either direction. Shouldn't the File Transfer take priority and deny the new connection?

Any and all help is always welcomed.
Best regards.
Sandy
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…