I am using Android Nearby Connections to send files through Wifi and messages through blutooth between two S21 devices.
Bluetooth messages are ok between the two devices but sending a file between the two devices fails. It seems that it is never received by the second device. The bluetooth metadata is well received. My code was working well before. Is it possible that a new version of Play Services broke it? Did I implement it well?
Here is my code for sending the file :
fun sendNearbyFile(connectionsClient : ConnectionsClient,
endpointId: String,
pfd: ParcelFileDescriptor, // Parcelable to the file to be sent
payloadMetadataPrefix : String,
metadata: String){
// compute file payload
val payloadFile = Payload.fromFile(pfd)
val payloadId = payloadFile.id
// send the FILE message
Log.d(TAG, "SENDING NEARBY file data")
connectionsClient.sendPayload(endpointId, payloadFile)
// send the BYTES message
Log.d(TAG,"SENDING NEARBY file metadata ($metadata)")
connectionsClient.sendPayload(
endpointId,
Payload.fromBytes("$payloadMetadataPrefix$payloadId:$metadata".toByteArray(Charsets.UTF_8))
)
}
Metadata is received on second device but not file data
Any idea?