Read weight from google fit

送分小仙女□ 提交于 2019-12-23 05:24:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!