I am writing a code to allow a user to add steps count to the Fitness History API within a defined period of time. I am using Fitness History API for Android referring to their documentation. I couldn't find the new method for setTimeInterval()
is there any new method or workaround for this?
int stepCountDelta = 950;
DataSet dataSet = DataSet.create(dataSource);
DataPoint dataPoint =
dataSet.createDataPoint().setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS);
Even getValue(Field.FIELD_STEPS).setInt(stepCountDelta);
setInt() has been deprecated.
As it says in the documentation:
public DataPoint setTimestamp (long timestamp, TimeUnit timeUnit)
This method is deprecated. use
DataPoint.Builder
to createDataPoint
instances.
So, do something like:
DataPoint dataPoint =
DataPoint.builder(dataSource)
.setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS)
.build();
DataSet.Builder dataSet = DataSet.builder(dataSource);
dataSet.addDataPoint(dataPoint);