Thursday, March 14, 2013

Re: [android-developers] bluetooth file transfer failure

In order to answer your question, we need to see the code where you create and set mmInstream, too. For all we know, you might have forgotten to connect it to any stream,

On Wednesday, March 13, 2013 9:28:08 PM UTC-7, akash roy wrote:
here  i am trying to send a file over bluetooth but its not sending any data.
here the main problem is that its not sending or receiving any data over the two devices but they are connected to each other.

<on configuring the bluetooth chat example.>


Sending code:


     File myFile = new File(message.toURI());
     Double nosofpackets = Math.ceil(((int) myFile.length() )/4096);
     System.out.println(nosofpackets);
     BufferedInputStream bis= new BufferedInputStream(new FileInputStream(myFile));
     byte[] send = new byte[4096];
     for(double i=0; i<nosofpackets; i++)
     {
          send = null ;
          a=bis.read(send, 0,send.length);
          Log.d("BluetoothChat", "data packet " + i);
          if(a==-1)
          {
              break;
          }
          mChatService.write(send);
     }


Receiving code :


    while((bytes = mmInStream.read(buffer))>0)
    {
    
    Log.d(TAG, "data is there for writing");
    bos.write(buffer);
    
    }

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate