Good day, i have a requirement where i need to send files(image/videos.. etc) through a bluetooth socket connection. Am using the Bluetooth chat example in the SDK as a guideline. I can connect successfully, but am having trouble converting the files in the sdcard to byte array so i can write it via an outputStream.
i can convert images using the following code:
//After getting the imageId from the cursor object
Bitmap bitmap = Media.getBitmap(getContentResolver(), imageUri);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, baos);
bytes[] bytes = baos.toByteArray();
but having trouble converting videos or other files, should i be using a ObjectOutputStream for all conversion or is there another way i can do this because i can't seem to convert a fileOutputStream to a byte Array? Thank you