Data is not sent using the bluetooth jack (Android)

I am trying to send a file using Android bluetooth sockets. I receive pairing requests, but, unfortunately, the data is not transmitted on my server side and the client side looks like this:

Server: (there is data for my application server)

public void run() { super.run(); BluetoothAdapter mBtadapter = BluetoothAdapter.getDefaultAdapter(); Log.i("bluetooth Adapter", "got adapter "+ mBtadapter.getAddress()); try { Ssocket = mBtadapter.listenUsingRfcommWithServiceRecord("CardXchange", uuid); Log.i("Socket", "Socket Acquired "+ Ssocket.toString()); } catch (IOException e) { e.printStackTrace(); } while(true){ if(read_flag()==1){ try { Toast.makeText(c, "flag is eventually 1", Toast.LENGTH_LONG).show(); Ssocket.close(); } catch (IOException e) { e.printStackTrace(); } break; } try { client_socket = Ssocket.accept(); if(client_socket!=null){ //this function is used to handle the connection when sockets get connected manageConnection1(client_socket); Ssocket.close(); break; } } catch (IOException e) { e.printStackTrace(); } } Log.i("breaked ", "oh god!! out of the loop "); } //implementation of the function private void manageConnection1(BluetoothSocket client_socket2) { // TODO Auto-generated method stub int bytes; Log.i("serevr chya manage connection madhe gela", "in servers manage connection "); File file = new File("/sdcard/myfolder/received.Xcard"); try { FileOutputStream fos = new FileOutputStream(file); try { InputStream is = client_socket2.getInputStream(); while((bytes = is.read(buffer, 0, 1024))>0){ fos.write(buffer, 0, 1024); } is.close(); fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { client_socket2.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } 

and the client side (the sending side is :)

 public void run(){ try { Method m = send_dev.getClass().getMethod("createRfcommSocket", new Class[] {int.class}); Csocket = (BluetoothSocket) m.invoke(send_dev, 1); Csocket.connect(); manageSendConnection(Csocket); }catch(Exception e){ e.printStackTrace(); } } //function to handle after connection is established. private void manageSendConnection(BluetoothSocket csocket) { // TODO Auto-generated method stub File f = new File("/sdcard/myfolder/card3.Xcard"); byte[] buffer = new byte[(int)f.length()]; try { FileInputStream fis = new FileInputStream(f); BufferedInputStream bis = new BufferedInputStream(fis); try { bis.read(buffer, 0, (int)f.length()); OutputStream os = csocket.getOutputStream(); os.write(buffer); os.close(); fis.close(); bis.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { csocket.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } 

I get a pairing request, but no data is sent. can someone help me find the problem and give a hint for a solution?

+2
android bluetooth file-transfer
source share

No one has answered this question yet.

See similar questions:

8
Android Bluetooth file transfer

or similar:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up Android emulator development?
3288
Correct use cases for Android UserManager.isUserAGoat ()?
2609
Is there a unique identifier for an Android device?
2510
How to keep Android activity state by saving instance state?
2097
Is there a way to run Python on Android?
1858
"Debug certificate expired" error in Android Eclipse plugins
1844
What is "Context" on Android?
1270
How to transfer data between actions in an Android application?

All Articles