6

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.

Uticensis
  • 105
  • 4
androidGuy
  • 5,553
  • 12
  • 39
  • 56
  • 2
    can you post the code snippet you are using ? Are you using RFCOMM sockets to transfer the image ? At the receiving end isn't it possible to collect the batches and combine it for the full image ? – Dennis Mathews Apr 21 '11 at 20:11
  • yeah finally collected in batches and combined it:) – androidGuy Jun 24 '11 at 12:02
  • Can you please share your code . I am facing same problem . – Ahmed Jan 27 '12 at 08:03
  • i just answered this problem on: http://stackoverflow.com/questions/11475168/example-how-to-send-big-images-over-bluetooth-and-also-more-text-data – Shulo Jul 13 '12 at 17:18
  • finally i could make the solution. I have just answered the solution in another thread of stackoverflow. please see the attached link for complete example of that: http://stackoverflow.com/questions/11475168/example-how-to-send-big-images-over-bluetooth-and-also-more-text-data you can also download a full example module for sending big images over bluetooth. – Shulo Jul 14 '12 at 07:57
  • Hello @androidGuy: I am working on same type of application in which I am receiving an Image at device end sent from an hardware via BLUETOOTH, but after accepting when I look at the image in my sdcard, it show "invalid file" message. I can see the size of image as the size of my byteArray i.e, 1024kb. Please suggest me. – Sam-In-TechValens Jan 04 '13 at 08:54

2 Answers2

1

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.

androidGuy
  • 5,553
  • 12
  • 39
  • 56
  • hi androidGuy i am also trying to transfer image via one blue tooth device to other but i am not getting all bytes length at reciving end as i also transfer some text via bluetooth and it works but for a single image transferring it not works ...i take the help for sending data from android developer Bluetooth chat application..as u also discussed above that image data would transfer in chunks but our default buffer size is limited so how to exceeds buffer size in both ends so that tranfer byte string value of image...pls help thaks – SRam Mar 15 '12 at 13:19
  • can u please share your code for sending and receiving end for image only...i will be greatly thankful of you.. – SRam Mar 15 '12 at 13:24
0

Try using an intent and calling setType("image/jpeg"), or png or whatever image file format you use

Amandeep Grewal
  • 1,801
  • 3
  • 19
  • 30