How do I get the data source for data points saved by Google Fit?

I'm trying to get data inserted by Google Fit, but only the one that was actually recorded by the sensors and not manually inserted. I was thinking about validating the data source, but it always returns null. Here is the code I used:

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

Fitness.HistoryApi.readData(mClient, readRequest)
        .setResultCallback(new ResultCallback<DataReadResult>() {
            @Override
            public void onResult(DataReadResult dataReadResult) {
                for (DataSet dataSet : dataReadResult.getDataSets()) {
                    Log.i(TAG, "Type: " + dataSet.getDataType().getName());
                    Log.i(TAG, "Source: " + dataSet.getDataSource().getName());
                }

                for (Bucket bucket : dataReadResult.getBuckets()) {
                    Log.i(TAG, "Bucket: " + bucket.getActivity());
                    for (DataSet dataSet : bucket.getDataSets()) {
                        Log.i(TAG, "Bucket data type: " + dataSet.getDataType().getName());
                        Log.i(TAG, "Bucket data source: " + dataSet.getDataSource().getName());
                    }
                }
            }
        });

      

Is it possible to skip manually inserted data or even get the sensor that was used to get the data?

+3


source to share





All Articles