Android Byte array
<p>I am sending 90000 bytes data from Bluetooth.I am getting chunks of 1024 bytes at receiving side. I need to collected them in single array and make an byte array. Not able to do that..</p>

<p>This is the code:</p>

<pre><code>    private final Handler mHandler = new Handler() {

    @Override
    public void handleMessage(Message msg) {
        System.out.println("***************handleMessage***************"+msg.obj);
        switch (msg.what) {
        case MESSAGE_STATE_CHANGE:
            if(D) Log.i(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
            switch (msg.arg1) {
            case BluetoothChatService.STATE_CONNECTED:
                mTitle.setText(R.string.title_connected_to);
                mTitle.append(mConnectedDeviceName);
                mConversationArrayAdapter.clear();
                break;
            case BluetoothChatService.STATE_CONNECTING:
                mTitle.setText(R.string.title_connecting);
                break;
            case BluetoothChatService.STATE_LISTEN:
            case BluetoothChatService.STATE_NONE:
                mTitle.setText(R.string.title_not_connected);
                break;
            }
            break;
        case MESSAGE_WRITE:
            byte[] writeBuf = (byte[]) msg.obj;
            // construct a string from the buffer
            String writeMessage = new String(writeBuf);
            mConversationArrayAdapter.add("Me:  " + writeMessage);
            break;
        case MESSAGE_READ:
            System.out.println("***************msg.obj***************"+msg.obj);
            byte[] readBuf = (byte[]) msg.obj;

            System.out.println("***************readBuf***************"+readBuf.length);
            Bitmap bmp=BitmapFactory.decodeByteArray(readBuf,0,readBuf.length);
            System.out.println("***************bmp***************"+bmp);

            //convert it back to an image
            ByteArrayInputStream imageStream = new ByteArrayInputStream(readBuf);
            Bitmap theImage = BitmapFactory.decodeStream(imageStream);
            System.out.println("***************theImage***************"+theImage);
            try
            {
            String filepath=Environment.getExternalStorageDirectory().getAbsolutePath();
            File file = new File(filepath, "barcode.PNG");
            FileOutputStream fos = new FileOutputStream(file); 
            BufferedOutputStream bos = new BufferedOutputStream(fos);
            theImage.compress(CompressFormat.JPEG, 100, fos);
            bos.flush();
            bos.close();
            }
            catch(Exception e)
            {
                System.out.println("***************Read***************"+e);
            }
</code></pre>

<p>case MESSAGE_READ: is calling again and again. I am sending image through bluetooth. at the sending side and getting 1024 bytes chunks at receiving side..</p>

<p>Any help would be appreciated.</p>

<p>Thanks</p>
