I am using Google health kit in my application . I know that Health kit doesn't provide the Sensor Steps Count directly .I read the google fit Documentation And i found that we can use Recording api for Step Count in background . So if it is possible to use Recording api and Sensor api To get the step Counts in background ,Please Tell me how to achieve this. I Want to sense the user activity and how many steps user took during that activity in background . Any help Would be appreciated .
As per the google fit documentation if my application subscribe for recording a data type then it will record the data of that type and store it into HISTORYAPI even if my app is not running. This is the subscription code
Fitness.RecordingApi.subscribe(fitnessClient, DataType.TYPE_ACTIVITY_SAMPLE)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
if (status.getStatusCode()
== FitnessStatusCodes.SUCCESS_ALREADY_SUBSCRIBED) {
Log.e(TAG, "Existing subscription for activity detected.");
} else {
Log.e(TAG, "Successfully subscribed activity !");
}
} else {
Log.e(TAG, "There was a problem subscribing.");
}
}
});
Fitness.RecordingApi.subscribe(fitnessClient,DataType.TYPE_STEP_COUNT_DELTA).
setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status arg0) {
if(arg0.isSuccess()){
Log.e("Steps Recording","Subcribe");
}
}
});
Now i have subscribe for the steps and activity. But till now it is not sensing anything . Can anyone explain What is the purpose of subscribe recording a datatype .