问题
I can't read a weight from Google Fit. When I make request to Google Fit for weight I get only name of weight field (weight) but DataPoints size is 0. What is wrong?
code:
DataReadRequest dataReadRequest = queryFitnessData();
DataReadResult dataReadResult = Fitness.HistoryApi.readData(getApiClient(), dataReadRequest)
.await(1000, TimeUnit.MILLISECONDS);
////////
private static DataReadRequest queryFitnessData() {
Calendar calendar = Calendar.getInstance();
Date date = new Date();
calendar.setTime(date);
long endTime = calendar.getTimeInMillis();
calendar.add(Calendar.YEAR, -1);
long startTime = calendar.getTimeInMillis();
DataReadRequest dataReadRequest = new DataReadRequest.Builder()
.read(DataType.TYPE_WEIGHT)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.build();
return dataReadRequest;
}
回答1:
Do you have weight added in the timerange you specified.Can you try
DataReadRequest dataReadRequest = new DataReadRequest.Builder()
.read(DataType.TYPE_WEIGHT)
.setTimeRange(1, endTime, TimeUnit.MILLISECONDS)
.setLimit(1)
.build();
来源:https://stackoverflow.com/questions/43859491/read-weight-from-google-fit