The whole code I am using to implement the Obex protocol. The bluetooth adapter on the PC side will connect to the phone. But program is blocked in the accept() method. And I got nothing to receive. Why>?>?????????
_server = BluetoothAdapter.getDefaultAdapter().listenUsingRfcommWithServiceRecord("HTC Hero", MY_UUID); _socket = _server.accept(); _server.close(); InputStream inputStream = _socket.getInputStream(); OutputStream outputStream = _socket.getOutputStream(); int read = -1; byte[] bytes = new byte[2048]; ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length); while ((read = inputStream.read(bytes)) != -1) { baos.write(bytes, 0, read); byte[] req = baos.toByteArray(); int op = req[0] & BIT_MASK; switch (op) { case OBEX_CONNECT: outputStream.write(new byte[] {(byte) OBEX_RESPONSE_OK, 0, 7, 16, 0, 4, 0 }); break; case OBEX_DISCONNECT: outputStream.write(new byte[] {(byte) OBEX_RESPONSE_OK, 0, 3, 0 }); break; case OBEX_PUT: outputStream.write(new byte[] {(byte) OBEX_RESPONSE_CONTINUE, 0, 3, 0 }); break; case OBEX_PUT_END: outputStream.write(new byte[] {(byte) OBEX_RESPONSE_OK, 0, 3, 0 }); break; default: outputStream.write(new byte[] {(byte) OBEX_RESPONSE_OK, 0, 3, 0 }); } baos = new ByteArrayOutputStream(bytes.length); } -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en