I have code that creates a PutDataRequest
to sync a Bitmap
with a wearable. My question is, do I need to close the ByteArrayOutputStream
in the code below, or does the DatApi
need it to stay open?
I'm pretty sure it needs to be closed. Just having a brain-fart moment.
PutDataMapRequest putRequest = PutDataMapRequest.create(path);
DataMap map = putRequest.getDataMap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.PNG, 100, stream);
Asset asset = Asset.createFromBytes(stream.toByteArray());
map.putAsset(mapKey, asset);
Wearable.DataApi.putDataItem(connection.getClient(), putRequest.asPutDataRequest());