I am trying to get steps, distance, calories from google fit API.
I use GoogleApiClient
for accessing data from Google Fit.
I ask per Google Fit permission also allow to access all data from Google Fit:
This permission pop up comes every time. I need to allow 4 to 5 times then I can possible to get steps from Google Fit .
What I need to do to get Google Fit permission very first time. So please help me to solve this issue.
mGoogleApiClient1 = new GoogleApiClient.Builder(this)
.addApi(Fitness.HISTORY_API)
.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
.addScope(new Scope(Scopes.FITNESS_BODY_READ_WRITE))
.addScope(new Scope(Scopes.FITNESS_LOCATION_READ_WRITE))
.addConnectionCallbacks(this)
.enableAutoManage(this, Constants.googleApi, this)
.build();
2. I use below API to get steps distance and calories Please tell why I am not getting consistent data from Google Fit. It always get steps data little more than original steps from Google Fit.
// get Steps data from bellow api
private void getStepDataForToday() {
DailyTotalResult result = Fitness.HistoryApi.readDailyTotal( mGoogleApiClient1, DataType.TYPE_STEP_COUNT_DELTA ).await(1, TimeUnit.MINUTES);
showDataSet(result.getTotal());
}
private void getDistanceDataForToday() {
DailyTotalResult result = Fitness.HistoryApi.readDailyTotal( mGoogleApiClient1, DataType.TYPE_DISTANCE_DELTA ).await(1, TimeUnit.MINUTES);
showDataSet(result.getTotal());
}
private void getCaloriesDataForToday() {
DailyTotalResult result = Fitness.HistoryApi.readDailyTotal( mGoogleApiClient1, DataType.TYPE_CALORIES_EXPENDED ).await(1, TimeUnit.MINUTES);
showDataSet(result.getTotal());
}
Thank you and waiting for help