Send Files via Bluetooth Socket Based on BluetoothChat Example
<p>Good day all, Based on a question i asked earlier, i have been able to convert files to byte Array in other to use the write method using this:</p>

<pre><code>public void sendFile(){
        Log.d(TAG, "sending data");
        InputStream inputStream = null;

      Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.INTERNAL_CONTENT_URI, "" +    filesID.get(0));
        Log.d(TAG, "obtained input stream here in recentDevices Activity");
        try {

            inputStream = getContentResolver().openInputStream(uri);
            ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();


            int buffersize = 1024;
            byte[] buffer = new byte[buffersize];

            int len = 0;
            while((len = inputStream.read(buffer)) != -1){
                byteBuffer.write(buffer, 0, len);
            }

            Log.d(TAG, "sending data to connected thread");
            bluetooth_service.write(byteBuffer.toByteArray());

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

        }

        finally{
            if(inputStream != null){
                try {
                    inputStream.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }


    }
</code></pre>

<p>and from the BluetoothChatService Example i have this write method in the connected thread:</p>

<pre><code>   public void write(byte[] out) {
        // Create temporary object
        ConnectedThread r;
        // Synchronize a copy of the ConnectedThread
        synchronized (this) {
            r = connectedThread;
        }
        // Perform the write unsynchronized
        r.write(out);
    }


/* Call this from the main Activity to send data to the remote device */
        public void write(byte[] bytes) {

            try {
                mmOutStream.write(bytes); // basically stuck here. nothing happens here
            } catch (IOException e) { }

            mHandler.sendEmptyMessage(RecentDevices.TRANSFER_COMPLETED);

        }
</code></pre>

<p>Am basically stuck in the write method of the connected Thread, nothing seems to happen there. i put a progress dialog to dismiss it after the handlers sends a TRANSFER_COMPLETED Method, but program is just stuck here. Have tried sending to a pc or another android device. no luck! Anyone had any success or with a solution?</p>
