Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Can';t从google fit HistoryApi获取热量_Android_Google Fit_Google Fit Sdk - Fatal编程技术网

Android Can';t从google fit HistoryApi获取热量

Android Can';t从google fit HistoryApi获取热量,android,google-fit,google-fit-sdk,Android,Google Fit,Google Fit Sdk,我使用HistoryApi获取消耗的卡路里,但我无法获取任何数据。 我的请求代码如下: private DataReadRequest queryFitnessData() { Calendar cal = Calendar.getInstance(); Date now = new Date(); cal.setTime(now); long endTime = cal.getTimeInMillis(); cal.add(Calendar.WEEK_

我使用HistoryApi获取消耗的卡路里,但我无法获取任何数据。 我的请求代码如下:

private DataReadRequest queryFitnessData() {

    Calendar cal = Calendar.getInstance();
    Date now = new Date();
    cal.setTime(now);
    long endTime = cal.getTimeInMillis();
    cal.add(Calendar.WEEK_OF_YEAR, -1);
    long startTime = cal.getTimeInMillis();

    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    Log.i(TAG, "Range Start: " + dateFormat.format(startTime));
    Log.i(TAG, "Range End: " + dateFormat.format(endTime));  

    DataReadRequest readRequest = new DataReadRequest.Builder()
            .aggregate(DataType.TYPE_CALORIES_EXPENDED,DataType.AGGREGATE_CALORIES_EXPENDED)
            .bucketByTime(1, TimeUnit.DAYS)
            .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
            .build();

    return readRequest;

}
这是我的错误日志:

请帮帮我


谢谢。

我解决了这个问题,因为问题中的开始时间和结束时间设置如果您能发布完整的代码,这将非常有帮助。在网上没有任何地方有卡路里计数的编码记录