Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer an Image via Bluetooth in Android

I am developing an Android application which needs an image to be transmitted from one android device to another via bluetooth.The image size goes upto 3 to 4 MB.The problem I am facing is that when i send the image in form of bytes, the image is received in parts not in single stretch. For eg i transferred an image whose length after converting to bytes was aroung 64k but at the receiving end it was received in batch of 1024.How to successfully transfer the image?

Is there any efficient way to transfer the image?

Am I doing it the right way or not?

Any help will be appreciated.

like image 420
androidGuy Avatar asked Nov 15 '22 00:11

androidGuy


1 Answers

OK atlast some how transmitted the image successfully:)Still I don't know why the images were transferred in batches.The problem was partially due to my buggy code,the buffer size was initialized only for 1024 bytes.That was one reason why it was transmitting in batch of 1024.I reinitialized buffer to a big value nonetheless the image was received in batches but batches of large size.Finally i collected them in batches and rearranged to form complete image.

like image 175
androidGuy Avatar answered Dec 23 '22 03:12

androidGuy