Closed rafaelcrz closed 7 years ago
User 1 takes a photo from camera, get it and send to other user.
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 0) { if (resultCode == RESULT_OK) { Bundle bundle = data.getExtras(); Bitmap bitmap = (Bitmap) bundle.get("data"); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream); byte[] bitmapByte = outputStream.toByteArray(); bluetoothSPP.send(bitmapByte, true); **//Send the Bitmap array** } }
User 2 receive the Bitmap byte[].
bluetoothspp.setOnDataReceivedListener(new BluetoothSPP.OnDataReceivedListener() { public void onDataReceived(byte[] data, String message) { Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); Glide.with(ChatActivity.this).load(bitmap ).asBitmap().into(imgFundo); //Use Glide for show Bitmap } });
But I always get an error and Glide can not display the image. I did a debug and the data comes in several parts, like an array of bytes.
Thanks
Does onActivityResult.bitmapByte.length match setOnDataReceivedListener.data.length ? If not, that's your issue. The data might be fragmented.
onActivityResult.bitmapByte.length
setOnDataReceivedListener.data.length
User 1 takes a photo from camera, get it and send to other user.
User 2 receive the Bitmap byte[].
But I always get an error and Glide can not display the image. I did a debug and the data comes in several parts, like an array of bytes.
Thanks