Android Tutorial AsyncStreamsObject - Send and receive objects instead of bytes

ToolboxZX

Member
Licensed User
Longtime User
Is it possible (or would it be faster) to send the file with B4XSerializator instead? I saw this link after looking around a bit on Erel's suggestion:
https://www.b4x.com/android/forum/threads/b4xobject-b4a-b4j-b4i-objects-serialization.48272/#content
It seems to imply that files might be transferable using it, but I am in need of an example on how to use the WriteB4XObject and ReadB4XObject commands to achieve this. I really am having a hard time finding examples of how to use B4XSerializator.
 

ToolboxZX

Member
Licensed User
Longtime User
You don't even need to use B4XSerializator in this case. Just read the file into an array of bytes and send it.

https://www.b4x.com/android/forum/threads/reading-a-file-to-list.62881/#post-397010
Thanks for the quick reply Erel.

Actually Kit I discovered the problem with why the Bluetooth communication was behaving so oddly. As it turns out this problem was also impacting the AsyncStreamsObject "ObjectSent" event from firing correctly. I was able to resolve both issues.

I am working on an adapted set of examples to share (B4A / B4J) so that anyone else wishing to use AsyncStreams can see a complete solution using it and Bluetooth.
 

ToolboxZX

Member
Licensed User
Longtime User
Well, in working on a new Bluetooth example, I stumbled across another issue that should be reproduce-able by anyone. I am hoping to upload the code soon, but in short here is what is happening, using the existing example with the jbluetooth driver instead of the jnetwork one.....
If you connect via bluetooth, you can use any of the buttons to transmit whatever you wish. (send file, send form, send drawing, send number).

That is until you try and send a larger file using the Send File button. (say a couple of megabytes).

As soon as you do that, the transfer starts to get "hung up" sending only a block of data at a time as it sees fit. But there is a caveat to this.

If the first thing you do is send the large file FIRST using the Send File Button, the example will transmit it just find and then allow you to send the smaller files no problems either. However try and send the same large file again and its transfer gets slowed way down and hung up. I have watched the eample in debug mode and it does not appear to be anything in the Main or AsyncStreamsObject modules as that all runs up to the point of departure where you are just waiting for the stream to finish, and watching the activity on the B4A side monitoring bytes recieved.
This has me a bit perplexed......
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…