Send File Google Wear To Mobile
I'm trying to send a file from my Google wear to my Nexus 5. I've read some tutorials and came up with the following code but my phone isn't receiving a file. Mobile: private Googl
Solution 1:
add a key value in the datamap: map.put("timestamp", System.currentmillions()) your phone do not receive any change event, because you put the same data item into the data api queue, try to put a different item
Solution 2:
I solved it by replacing this
PutDataRequestputDataRequest= PutDataRequest.create("/image");
putDataRequest.putAsset("debugFile", asset);
Wearable.DataApi.putDataItem(client, putDataRequest);
with this
PutDataMapRequestdataMap= PutDataMapRequest.create("/image");
dataMap.getDataMap().putAsset("debugFile", asset);
PutDataRequestrequest= dataMap.asPutDataRequest();
PendingResult<DataItemResult> pendingResult = Wearable.DataApi.putDataItem(client, request);
pendingResult.setResultCallback(newResultCallback<DataItemResult> () {
@OverridepublicvoidonResult(DataItemResult dataItemResult) {
// something
}
} );
now it works for me
Solution 3:
Main error:
// Read data from the Asset and write it to a file on external storagefinalFilefile=newFile(dir, "sensordata.txt");
if (!file.exists()) {
file.mkdirs(); <---- you create a directory instead a file
}
and that's why you see not the error.
fOut.flush();
fOut.close();
} catch (Exception e) { <--- hide exception
}
File exists as directory and a stream can't be open it
FileOutputStreamfOut=newFileOutputStream(file); <-- throw exception
Post a Comment for "Send File Google Wear To Mobile"